summaryrefslogtreecommitdiffstats
path: root/src/widgets/kernel/qapplication.cpp
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@qt.io>2019-10-15 14:18:40 +0200
committerTor Arne Vestbø <tor.arne.vestbo@qt.io>2020-09-07 14:41:16 +0200
commit89f7a2759c6b51343d0a1ca5a82d575abba04e0c (patch)
treed80ce26bfd31c8118b16b6895e147d7647a86967 /src/widgets/kernel/qapplication.cpp
parent0ae5b8af9c2af514f316211b71a03defc0f1b65a (diff)
Deliver Quit event when calling QCoreApplication::quit()
Instead of QCoreApplication::quit() directly calling exit(0), which would leave QGuiApplication and client code out of the loop, we now send the Quit event, and let it pass through event delivery, before finally ending up in QCoreApplication::event(), where we call exit(0). This has the advantage that QGuiApplication can ensure all windows are closed before quitting, and if any of those windows ignore the close event the quit will be aborted. This aligns the behavior of synthetic quits via QCoreApplication::quit() with spontaneous quits from the platform via QGuiApplicationPrivate::processApplicationTermination. Clients who wish to exit the application without any event delivery or potential user interaction can call the lower level exit() function directly. [ChangeLog][QtGui] Application termination via qApp->quit() will now deliver Quit events to the application, which in turn will result in application windows being closed as part of the application quit, with an option to cancel the application quit by ignoring the close event. Clients who explicitly want to exit the application without any user interaction should call QCoreApplication::exit() explicitly. Task-number: QTBUG-45262 Task-number: QTBUG-33235 Task-number: QTBUG-72013 Task-number: QTBUG-59782 Change-Id: Id4b3907e329b9ecfd936fe9a5f8a70cb66b76bb7 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/widgets/kernel/qapplication.cpp')
-rw-r--r--src/widgets/kernel/qapplication.cpp16
1 files changed, 7 insertions, 9 deletions
diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp
index 5313d5ff67..a8590c7903 100644
--- a/src/widgets/kernel/qapplication.cpp
+++ b/src/widgets/kernel/qapplication.cpp
@@ -1605,19 +1605,17 @@ retry:
Closes all top-level windows.
This function is particularly useful for applications with many top-level
- windows. It could, for example, be connected to a \uicontrol{Exit} entry in the
- \uicontrol{File} menu:
-
- \snippet mainwindows/mdi/mainwindow.cpp 0
+ windows.
The windows are closed in random order, until one window does not accept
- the close event. The application quits when the last window was
- successfully closed; this can be turned off by setting
- \l quitOnLastWindowClosed to false.
+ the close event. The application quits when the last window was successfully
+ closed, unless \l quitOnLastWindowClosed is set to false. To trigger application
+ termination from e.g. a menu, use QCoreApplication::quit() instead of this
+ function.
\sa quitOnLastWindowClosed, lastWindowClosed(), QWidget::close(),
- QWidget::closeEvent(), lastWindowClosed(), QCoreApplication::quit(), topLevelWidgets(),
- QWidget::isWindow()
+ QWidget::closeEvent(), lastWindowClosed(), QCoreApplication::quit(),
+ topLevelWidgets(), QWidget::isWindow()
*/
void QApplication::closeAllWindows()
{