Strange: QProgressDialog keeps appearing when clicking on menus on the main window
-
I have a QProgressDialog declared in the MainWindow class. It is setup in the MainWindow constructor as follows:
dialog = new QProgressDialog(tr("Processing") + "...", tr("Cancel"), 0, 4, this); dialog->setWindowModality(Qt::WindowModal);It is strange but when I click on menu (headings) on the main window, the dialogue appears all by it self without any code calling it or without clicking on any menu item.
-
I have a QProgressDialog declared in the MainWindow class. It is setup in the MainWindow constructor as follows:
dialog = new QProgressDialog(tr("Processing") + "...", tr("Cancel"), 0, 4, this); dialog->setWindowModality(Qt::WindowModal);It is strange but when I click on menu (headings) on the main window, the dialogue appears all by it self without any code calling it or without clicking on any menu item.
@Guerrian
then there must be more code which causing this behavior ;) -
Hi
Actually i could reproduce it
with only that 2 lines of code

I simply run program and wait a moment. ( 5-8 secs) then it pops :)
(also in a new clean default GUI project with no menus ) -
I need this to be in the scope of the main window. How do I control this dialogue and prevent it from appearing randomly?
Update
I tried adding "reset", seems to have solved the problem:dialog = new QProgressDialog(tr("Processing") + "...", tr("Cancel"), 0, 4, this); dialog->setWindowModality(Qt::WindowModal); dialog->reset(); -
Hi
try without
dialog->setWindowModality(Qt::WindowModal);
and see if that makes a difference. -
Hi
try without
dialog->setWindowModality(Qt::WindowModal);
and see if that makes a difference. -
@Guerrian
Yeah, u can set same place you call show()
It was just for test.Its a bit odd it pops up.Never mind. :)
Reading the docs , it clear states why it pops.
its due to setMinimumDuration
http://doc.qt.io/qt-5/qprogressdialog.html#minimumDuration-prop -
@Guerrian
Yeah, u can set same place you call show()
It was just for test.Its a bit odd it pops up.Never mind. :)
Reading the docs , it clear states why it pops.
its due to setMinimumDuration
http://doc.qt.io/qt-5/qprogressdialog.html#minimumDuration-prop@mrjj
Without this line it still pops up:dialog->setWindowModality(Qt::WindowModal);I found that it does not pop up if I use reset at the start:
dialog->setWindowModality(Qt::WindowModal); dialog->reset();...use this if the process is cancelled:
dialog->close();...and do nothing if the process finishes ie. the progress bar reaches maximum, because it auto resets in that case.
-
@mrjj
Without this line it still pops up:dialog->setWindowModality(Qt::WindowModal);I found that it does not pop up if I use reset at the start:
dialog->setWindowModality(Qt::WindowModal); dialog->reset();...use this if the process is cancelled:
dialog->close();...and do nothing if the process finishes ie. the progress bar reaches maximum, because it auto resets in that case.
-
@mrjj
OK, but does it explain about reset? It says about showing "any progress", this seems to apply when there is zero progress. Whereas reset can actually hide the dialogue.