PDA

View Full Version : Dialog closes immediately



bruccutler
21st February 2007, 22:57
Hello again,
I've got a strange one going on now. I have two dialogs that I open. I do so with the .exec() to make them modal. When I close the first one, I open the second one with .exec(). It immediately returns. I stepped into the Qt code and found that it does this because at line #153 of qeventloop.cpp, the d->threadData->quitNow flag is set. If I skip over the next line (return -1 ), it comes up just fine and functions normally.

I'm going to continue to search for what is going on, but if anyone has a clue, please let me know.

Thanks for all the help
- BRC

jacek
21st February 2007, 23:01
Do you happen to open those dialogs in main()?

bruccutler
21st February 2007, 23:08
Do you happen to open those dialogs in main()?

No - I've created a QObject based class with a slot that I call from main with QMetaObject::invokeMethod() call using Qt::QueuedConnection parameter. The first dialog comes up just fine (usually). But sometimes even the first dialog closes before I see it too. So, perhaps this is the problem. The support people at Qt told me to do it this way. Before I had all of the dialog calls in main().

The main application goes on to the app.exec() call.

- BRC

bruccutler
21st February 2007, 23:13
More information -
I can't even reopen the first dialog. It appears that there is some global variable that is getting set when I close the first dialog that causes all other dialogs to want to close as well. It's almost like I've set the system to close the entire application.

hmmmm - still researching.

- BRC

jacek
21st February 2007, 23:13
No - I've created a QObject based class with a slot that I call from main with QMetaObject::invokeMethod() call using Qt::QueuedConnection parameter. [...]
The main application goes on to the app.exec() call.
I see, but the solution is the is the same:


int main( int argc, char **argv ) {
QApplication app( argc, argv );
app.setQuitOnLastWindowClosed( false );
...
app.setQuitOnLastWindowClosed( true );
return app.exec();
}
QApplication::setQuitOnLastWindowClosed() (http://doc.trolltech.com/4.2/qapplication.html#quitOnLastWindowClosed-prop)

bruccutler
21st February 2007, 23:18
I see, but the solution is the is the same:


int main( int argc, char **argv ) {
QApplication app( argc, argv );
app.setQuitOnLastWindowClosed( false );
...
app.setQuitOnLastWindowClosed( true );
return app.exec();
}
QApplication::setQuitOnLastWindowClosed() (http://doc.trolltech.com/4.2/qapplication.html#quitOnLastWindowClosed-prop)

Thanks - I had just encountered that option and was going to see if it might be the issue. Thanks, I think this is what is happening.

BRC