Reputation: 884
I'm looking for a documentation about the things that happen after/while calling the quit() of a Qt application. The question stems from a problem that I had with handling return values of open QDialogs on quit(). I would like to clarify the following sequence:
So the program flow is: As long as a modal dialog is open the event loop of this dialog is running. When quit() is called QDialog::exec() (the event loop of the modal dialog) is returning which could mean that a lot of additional code is run and even signal/slots could be executed when they are in the same thread. Then the normal event loop is not processed anymore, just aboutToQuit() and the destructors are called.
Is this description correct? Can someone point me to a Qt documentation that explains the interaction of quit() and QDialog? And what happens when I call exec() of a QDialog after a exec() of QDialog returned due to the quit() call? Who is then closing this QDialog?
Thanks, I'm a bit confused about all those interactions.
Edit: It appears that calls to exec() of a QDialog are rejected if the quit() method was called before. So I guess that Qt internally knows that the application is about to quit so all further QDialogs return "rejected" immediately.
Upvotes: 1
Views: 912
Reputation: 5207
I am not sure what you mean with "closeEvent is not called for QDialogs" because that is where it calls reject()
: QDialog::closeEvent() code
As for the interaction between various exec()
and quit()
:
QDialog::exec()
uses a nested QEventLoop
: QDialog::exec() codeQCoreApplication::quit()
loops through all nested event loops on tells them to exit: QCoreApplication::exec() codeUpvotes: 1
Reputation: 88
It seems logical to me that all open dialogs would have to be "rejected" before the main program can close. (This should be a comment but I don't have enough rep yet >.< ).
Upvotes: 0