Hi,

I will show u 2 situations, and the difference between those two is only a switch concerning 2 lignes

code 1 :

Qt Code:
  1. Window::Window()
  2. {
  3. AppVars::urlRSSlist << "http://rss.lemonde.fr/c/205/f/3050/index.rss";
  4.  
  5.  
  6. for(int i=0;i<AppVars::urlRSSlist.size();i++){
  7. qDebug() << "enter for loop for i = "+QString::number(i);
  8. netManList<< new QNetworkAccessManager(this);
  9. listRequest<<QNetworkRequest(QUrl(AppVars::urlRSSlist[i]));
  10. listReply<<netManList[i]->get(listRequest[i]);
  11. }
  12. QObject::connect (listReply[0], SIGNAL(readyRead()), this, SLOT(downloadedRSSalaune())) ;
  13.  
  14. }
  15.  
  16. void Window::downloadedRSSalaune(){
  17.  
  18. qDebug() << listReply[0]->errorString();
  19.  
  20. if(listReply[0]->error() != QNetworkReply::NoError)
  21. return;
  22. //HERE
  23. QByteArray data =QByteArray(listReply[0]->readAll());
  24. qDebug() <<listReply[0]->readAll();
  25.  
  26. int statusCode = listReply[0]->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
  27. qDebug() << QVariant(statusCode).toString();
  28. }
To copy to clipboard, switch view to plain text mode 

code 2 :

Qt Code:
  1. Window::Window()
  2. {
  3. AppVars::urlRSSlist << "http://rss.lemonde.fr/c/205/f/3050/index.rss";
  4.  
  5.  
  6. for(int i=0;i<AppVars::urlRSSlist.size();i++){
  7. qDebug() << "enter for loop for i = "+QString::number(i);
  8. netManList<< new QNetworkAccessManager(this);
  9. listRequest<<QNetworkRequest(QUrl(AppVars::urlRSSlist[i]));
  10. listReply<<netManList[i]->get(listRequest[i]);
  11. }
  12. QObject::connect (listReply[0], SIGNAL(readyRead()), this, SLOT(downloadedRSSalaune())) ;
  13.  
  14. }
  15.  
  16. void Window::downloadedRSSalaune(){
  17.  
  18. qDebug() << listReply[0]->errorString();
  19.  
  20. if(listReply[0]->error() != QNetworkReply::NoError)
  21. return;
  22. //AND HERE
  23. qDebug() <<listReply[0]->readAll();
  24. QByteArray data =QByteArray(listReply[0]->readAll());
  25.  
  26.  
  27. int statusCode = listReply[0]->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
  28. qDebug() << QVariant(statusCode).toString();
  29. }
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 :
Qt Code:
  1. "enter for loop for i = 0"
  2. "Unknown error"
  3. ""
  4. "200"
To copy to clipboard, switch view to plain text mode 

result 2 :
Qt Code:
  1. "enter for loop for i = 0"
  2. "Unknown error"
  3. "<?xml [................................. lot of lines...............]"
  4. "200"
To copy to clipboard, switch view to plain text mode 

What's going on here ?

N.B. :
Qt Code:
  1. QList<QNetworkAccessManager*> netManList;
  2. QList<QNetworkRequest> listRequest;
  3. QList<QNetworkReply*> listReply;
To copy to clipboard, switch view to plain text mode