determine source of app quiting
-
Hi,
when I close my app by clicking at X button in the top right corner of the window (or pressing Alt + F4), I want to show a yes-no dialog "Do you really want to close the app?". I do that by overridingQMainWindow::closeEvent
method.But when I try to turn off my pc (Windows 10) with my app still running, turning off is interrupted by this dialog. And I don't want to display dialog in this case.
Is there a way, how to determine if app is closing because of direct user interaction (and display a dialog in this case) or because of the system turning off (and don't display dialog)?
-
I haven't tried it, but the value of spontaneous() for the QEvent passed to closeEvent() will probably be true when it's initiated by the system shutting down.
This doesn't work, see SGaist's comment below. -
Hi,
You need to check the session management. You can then disable the custom close handling.