I have a simple class Networking with a:
private:
QNetworkAccessManager *httpclient;
I create an object in the constructor and connect signal and slot:
httpclient = new QNetworkAccessManager(this);
connect(httpclient, SIGNAL(finished(QNetworkReply*)), this, SLOT(httpRequestFinished(QNetworkReply*)));
Now I am going to call the QNetworkAccessManager's get method via a public method getPage:
void Networking::getPage(const QString &uri)
{
QNetworkRequest request;
request.setUrl(uri);
httpclient->get(request);
}
I expect that httpRequestFinished gets called, but it's not. I also tried it this for testing purposes:
void Networking::getPage(const QString &uri)
{
QNetworkRequest request;
request.setUrl(uri);
reply = httpclient->get(request);
connect(reply, SIGNAL(finished()), this, SLOT(httpReplyFinished()));
}
where reply is properly defined in file networking.h:
private:
QNetworkAccessManager *httpclient;
QNetworkReply *reply;
Nothing changed! But if I access reply->bytesAvailable() after the get-Request all signals are emitted at the same time! I'm searching now for hours but don't know what I am doing wrong.