My QNetworkRequest routine works fine and I get the info from the website that I want when I do this:
QNetworkAccessManager* nam = new QNetworkAccessManager(this);
QObject::connect(nam,
SIGNAL(finished
(QNetworkReply
*)),
this,
SLOT(finished
(QNetworkReply
*)));
//first
url.setUrl("http://www.google.com");
reply = nam->get(QNetworkRequest(url));
QNetworkAccessManager* nam = new QNetworkAccessManager(this);
QNetworkReply* reply; QUrl url; QString urlstring;
QObject::connect(nam, SIGNAL(finished(QNetworkReply*)),this, SLOT(finished(QNetworkReply*)));
//first
url.setUrl("http://www.google.com");
reply = nam->get(QNetworkRequest(url));
To copy to clipboard, switch view to plain text mode
However, when I do it more than once, I always get the data for the latest request only:
QNetworkAccessManager* nam = new QNetworkAccessManager(this);
QObject::connect(nam,
SIGNAL(finished
(QNetworkReply
*)),
this,
SLOT(finished
(QNetworkReply
*)));
//first
url.setUrl("http://www.google.com");
reply = nam->get(QNetworkRequest(url));
//second
url.setUrl("http://www.yahoo.com");
reply = nam->get(QNetworkRequest(url));
//third
url.setUrl("http://www.hotmail.com");
reply = nam->get(QNetworkRequest(url));
QNetworkAccessManager* nam = new QNetworkAccessManager(this);
QNetworkReply* reply; QUrl url; QString urlstring;
QObject::connect(nam, SIGNAL(finished(QNetworkReply*)),this, SLOT(finished(QNetworkReply*)));
//first
url.setUrl("http://www.google.com");
reply = nam->get(QNetworkRequest(url));
//second
url.setUrl("http://www.yahoo.com");
reply = nam->get(QNetworkRequest(url));
//third
url.setUrl("http://www.hotmail.com");
reply = nam->get(QNetworkRequest(url));
To copy to clipboard, switch view to plain text mode
Do you know why that is??
Here's my slot if that matters:
void MyClass::finished(QNetworkReply* reply)
{
QVariant statusCodeV
= reply
->attribute
(QNetworkRequest
::HttpStatusCodeAttribute);
if (statusCodeV.toInt()==200){
//do something
}
else{
//do something
}
delete reply;
}
void MyClass::finished(QNetworkReply* reply)
{
QVariant statusCodeV = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute);
if (statusCodeV.toInt()==200){
//do something
}
else{
//do something
}
delete reply;
}
To copy to clipboard, switch view to plain text mode
Thanks!
Bookmarks