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:
iteration = 0;
startSlot();
dlg.exec();
//...
void X:startSlot(){
iteration++;
if(iteration<1000)
QTimer::singleShot(0,
this,
SLOT(startSlot
()));
}
QProgressDialog dlg(this);
iteration = 0;
startSlot();
dlg.exec();
//...
void X:startSlot(){
iteration++;
if(iteration<1000)
QTimer::singleShot(0, this, SLOT(startSlot()));
}
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.
Bookmarks