Hi,
I will show u 2 situations, and the difference between those two is only a switch concerning 2 lignes
code 1 :
Window::Window()
{
AppVars::urlRSSlist << "http://rss.lemonde.fr/c/205/f/3050/index.rss";
for(int i=0;i<AppVars::urlRSSlist.size();i++){
qDebug
() <<
"enter for loop for i = "+QString::number(i
);
netManList<< new QNetworkAccessManager(this);
listRequest<<QNetworkRequest
(QUrl(AppVars
::urlRSSlist[i
]));
listReply<<netManList[i]->get(listRequest[i]);
}
QObject::connect (listReply
[0],
SIGNAL(readyRead
()),
this,
SLOT(downloadedRSSalaune
())) ;
}
void Window::downloadedRSSalaune(){
qDebug() << listReply[0]->errorString();
if(listReply[0]->error() != QNetworkReply::NoError)
return;
//HERE
qDebug() <<listReply[0]->readAll();
int statusCode = listReply[0]->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
qDebug
() <<
QVariant(statusCode
).
toString();
}
Window::Window()
{
AppVars::urlRSSlist << "http://rss.lemonde.fr/c/205/f/3050/index.rss";
for(int i=0;i<AppVars::urlRSSlist.size();i++){
qDebug() << "enter for loop for i = "+QString::number(i);
netManList<< new QNetworkAccessManager(this);
listRequest<<QNetworkRequest(QUrl(AppVars::urlRSSlist[i]));
listReply<<netManList[i]->get(listRequest[i]);
}
QObject::connect (listReply[0], SIGNAL(readyRead()), this, SLOT(downloadedRSSalaune())) ;
}
void Window::downloadedRSSalaune(){
qDebug() << listReply[0]->errorString();
if(listReply[0]->error() != QNetworkReply::NoError)
return;
//HERE
QByteArray data =QByteArray(listReply[0]->readAll());
qDebug() <<listReply[0]->readAll();
int statusCode = listReply[0]->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
qDebug() << QVariant(statusCode).toString();
}
To copy to clipboard, switch view to plain text mode
code 2 :
Window::Window()
{
AppVars::urlRSSlist << "http://rss.lemonde.fr/c/205/f/3050/index.rss";
for(int i=0;i<AppVars::urlRSSlist.size();i++){
qDebug
() <<
"enter for loop for i = "+QString::number(i
);
netManList<< new QNetworkAccessManager(this);
listRequest<<QNetworkRequest
(QUrl(AppVars
::urlRSSlist[i
]));
listReply<<netManList[i]->get(listRequest[i]);
}
QObject::connect (listReply
[0],
SIGNAL(readyRead
()),
this,
SLOT(downloadedRSSalaune
())) ;
}
void Window::downloadedRSSalaune(){
qDebug() << listReply[0]->errorString();
if(listReply[0]->error() != QNetworkReply::NoError)
return;
//AND HERE
qDebug() <<listReply[0]->readAll();
int statusCode = listReply[0]->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
qDebug
() <<
QVariant(statusCode
).
toString();
}
Window::Window()
{
AppVars::urlRSSlist << "http://rss.lemonde.fr/c/205/f/3050/index.rss";
for(int i=0;i<AppVars::urlRSSlist.size();i++){
qDebug() << "enter for loop for i = "+QString::number(i);
netManList<< new QNetworkAccessManager(this);
listRequest<<QNetworkRequest(QUrl(AppVars::urlRSSlist[i]));
listReply<<netManList[i]->get(listRequest[i]);
}
QObject::connect (listReply[0], SIGNAL(readyRead()), this, SLOT(downloadedRSSalaune())) ;
}
void Window::downloadedRSSalaune(){
qDebug() << listReply[0]->errorString();
if(listReply[0]->error() != QNetworkReply::NoError)
return;
//AND HERE
qDebug() <<listReply[0]->readAll();
QByteArray data =QByteArray(listReply[0]->readAll());
int statusCode = listReply[0]->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
qDebug() << QVariant(statusCode).toString();
}
To copy to clipboard, switch view to plain text mode
as you can see, only qDebug() and QByteArray calling order differ between those code, and I've got 2 different results :
result 1 :
"enter for loop for i = 0"
"Unknown error"
""
"200"
"enter for loop for i = 0"
"Unknown error"
""
"200"
To copy to clipboard, switch view to plain text mode
result 2 :
"enter for loop for i = 0"
"Unknown error"
"<?xml [................................. lot of lines...............]"
"200"
"enter for loop for i = 0"
"Unknown error"
"<?xml [................................. lot of lines...............]"
"200"
To copy to clipboard, switch view to plain text mode
What's going on here ?
N.B. :
QList<QNetworkAccessManager*> netManList;
QList<QNetworkRequest> listRequest;
QList<QNetworkReply*> listReply;
QList<QNetworkAccessManager*> netManList;
QList<QNetworkRequest> listRequest;
QList<QNetworkReply*> listReply;
To copy to clipboard, switch view to plain text mode
Bookmarks