Hey,

I'm trying to make an application that is designed to grab data from a website in a thread but for some reason, despite having no errors in compile/run, the slot never seems to get fired.

Heres my code:

Qt Code:
  1. void itemthread::run() {
  2. int i;
  3. QTextStream out(stdout, QIODevice::WriteOnly);
  4. for(i=1; i < 10; i++) {
  5. out << i;
  6. QNetworkAccessManager *manager = new QNetworkAccessManager();
  7. connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(gotData(QNetworkReply *)));
  8.  
  9. QString url_string = QString("http://www.someurl.com?arg=%1").arg(i);
  10. QUrl url(url_string);
  11.  
  12. QNetworkRequest request;
  13. request.setUrl(url);
  14. request.setRawHeader("User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)");
  15.  
  16. manager->get(request);
  17. }
  18. }
To copy to clipboard, switch view to plain text mode 

"itemthread" is a class that extends QThread. My slot "gotData" never seems to be fired, no matter how long you leave the program running. I had to remove this from new QNetworkAccessManager because it was causing a error during runtime ("QObject: Cannot create children for a parent that is in a different thread.").

How can I request URLs while inside a QThread?

Thanks,

Tom