I'd suggest doing it a bit another way. You need to implement your functionality in a slot that can be called multiple times - once for every iteration. Then create the progress dialog, make a connection between a single shot timer and your slot and call exec() on the dialog.

Set a 0 timeout for the timer and at the end of your slot start a 0-timeout single shot timer again. Something like:
Qt Code:
  1. QProgressDialog dlg(this);
  2. iteration = 0;
  3. startSlot();
  4. dlg.exec();
  5. //...
  6. void X:startSlot(){
  7. iteration++;
  8. if(iteration<1000)
  9. QTimer::singleShot(0, this, SLOT(startSlot()));
  10. }
To copy to clipboard, switch view to plain text mode 

The main idea is to make sure you call exec on the progress dialog. See if your app crashes then.