PDA

View Full Version : Modeless dialog disappearing



Raccoon29
14th September 2007, 11:42
Hi everyone!

Well, my problem is simple:
I want to show a dialog that is containing a ProgressBar, that notices about the progress of a parallel long process, while the user stays working normally on the main window. I would like this dialog in "Find & Replace" style of word-processors.
The manual talks about a :

dialog->setModal(TRUE);
dialog->show();
but I saw many examples that do not use setModal function, just show().
So I used just show() and the result is that the dialog appears and disappears quickly!
Could it be because of the missing of this piece of code I saw somewhere? :

dialog->show();
dialog->raise();
dialog->activateWindow();
or maybe not. Why this "magician trick" dialog? :eek:

Thank you a big lot to who will help!

PS: to apply and test changes I have to wait for a compilation of about three hours long, but I'm starting to have no time left...so please give me straight answers... :o thanks a lot!

marcel
14th September 2007, 18:10
Hard to say.
What does the dialog actually do? Maybe you have an error somewhere else in your code, for example in the communication between the dialog and the parallel process.

Some code might clear things

Raccoon29
14th September 2007, 19:06
I thought it too, but the code doesn't present any sort of cleaning out of control...
Additionally I noticed that exec() instead of show() , shows the dialog perfectly but it doesn't permit interaction with the main window behind the dialog, because it is modal.
So maybe it is a problem dued to show() ?

What does the dialog actually do?
the dialog, when pushed its button, comes up for a fifth of second and then disappears.
:confused:

jpn
14th September 2007, 20:04
the dialog, when pushed its button, comes up for a fifth of second and then disappears.
Just to ensure, you are allocating the dialog on the heap (like the code snippet in the first post suggests), right? Allocating the dialog accidentally on the stack usually leads to similar problems than you have described.

heap vs. stack


{
QDialog* dialog = new QDialog(this);
dialog->show();
} // dialog remains alive



{
QDialog dialog(this);
dialog.show();
} // dialog goes out of scope

On the other hand, QDialog::exec() makes it work because it blocks:


{
QDialog dialog(this);
dialog.exec(); // starts an event loop and blocks as long as the dialog is visible
}

Raccoon29
15th September 2007, 12:38
uhmmm, yes. It must be so :D
Oh God, you all are incredible...
I'm going to test and report soon, thank you!