I have n00b problem, I cannot force HTTP GET requests from my Qt code ...
Here is the code that should work:
void MainWindow::requestShowPage(){ QNetworkAccessManager *manager = new QNetworkAccessManager(this); connect(manager,SIGNAL(finished(QNetworkReply*)),this,SLOT(requestReceived(QNetworkReply*))); manager->get(QNetworkRequest(QUrl("http://google.com"))); } void MainWindow::requestReceived(QNetworkReply* reply){ QString replyText; replyText.fromAscii(reply->readAll()); ui->txt_debug->appendPlainText(replyText); }
But the problem is that it just doesn't work: In requestReceived(QNetworkReply* reply) , replyText seems empty, reply->error() returns 0 and reply->errorString() returns "Unknown error". I really don't know what to do right now ...
Any idea?
source share