That did work, but I am having trouble dealing with the responses, since I'm not very familiar with the QHttp. I tried to set up a request in one function, then I set up a slot in the and it is supposed to run the second function listed below.
I guess I'm not sure how to see errors or successes so I know what is going on with the QHttp request. Also, I don't think I set up the slot properly, the program compiles fine but then it says:
Object::connect: No such signal QHttp::readyRead(http) in ..\htmldownload\mainwindow.cpp:12
Object::connect: (receiver name: 'MainWindow')
The request function
void MainWindow::gethtml(){
QString address
= ui
->lineEdit
->text
();
header.setValue("Host", "qt.nokia.com");
http->setHost("qt.nokia.com");
http->request(header);
}
void MainWindow::gethtml(){
QString address = ui->lineEdit->text();
http = new QHttp;
QHttpRequestHeader header("GET", QUrl::toPercentEncoding("/index.html"));
header.setValue("Host", "qt.nokia.com");
http->setHost("qt.nokia.com");
http->request(header);
}
To copy to clipboard, switch view to plain text mode
The Slot
MainWindow
::MainWindow(QWidget *parent
) : ui(new Ui::MainWindow)
{
ui->setupUi(this);
connect(http, SIGNAL(readyRead(http)), this, SLOT(readthetext()));
}
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
http = new QHttp;
connect(http, SIGNAL(readyRead(http)), this, SLOT(readthetext()));
}
To copy to clipboard, switch view to plain text mode
Code I'm hoping will run when the readReady signal is activated
void MainWindow::readthetext(){
ui->textEdit->setText("IT'S READY!");
QString downloadedtext
= http
->readAll
();
ui->textEdit->setText(downloadedtext);
}
void MainWindow::readthetext(){
ui->textEdit->setText("IT'S READY!");
QString downloadedtext = http->readAll();
ui->textEdit->setText(downloadedtext);
}
To copy to clipboard, switch view to plain text mode
Thank you in advance
Bookmarks