I have kind of a n00b problem, I can't seem to make HTTP GET requests from my Qt Code...
Here is the code supposed to 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 this just doesn't work: In requestReceived(QNetworkReply* reply)
, replyText
seems empty, reply->error()
returns 0
and reply->errorString()
returns "Unknown Error". I don't really know what to do right now...
Any idea?