timmu
24th August 2009, 15:27
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);
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));
However, when I do it more than once, I always get the data for the latest request only:
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));
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;
}
Thanks!
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));
However, when I do it more than once, I always get the data for the latest request only:
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));
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;
}
Thanks!