Currently in a project I'm working on I'm using a slightly modified version of this (emits fileSaved() and takes a save path) to download files like so:

Qt Code:
  1. QEventLoop imageLoop;
  2. QDownloader *downloader = new QDownloader();
  3. connect(downloader, SIGNAL(fileSaved()), &imageLoop, SLOT(quit()));
  4.  
  5. for(int i = 0; i < imageURLs.length(); i++) {
  6. progressDialog->setValue((int)(100 * (double)i / imageURLs.length()));
  7. progressDialog->setLabelText("Downloading image: " + QString::number(i + 1) + "/" + QString::number(imageURLs.length()));
  8.  
  9. if(progressDialog->wasCanceled())
  10. break;
  11.  
  12. downloader->setFile(imageURLs.at(i), QDir::homePath() + "/images/" + imageNames.at(i) + ".jpg");
  13. imageLoop.exec();
  14. }
To copy to clipboard, switch view to plain text mode 

The program crashes sometimes doing this and I was wondering what I am doing wrong or what is a more common or appropriate way to accomplish this.

Thanks