Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

System menu close button(X) pressing interception



  • Hi all!

    I need to distinguish somehow whether the X button was pressed or application is requested to be closed by some other method. I need it because I've overloaded closeEvent() and ignored the event inside. But it prevents an OS from the graceful logout. So I need the method to not close the application by the X button pressing and don't mess with the logout mechanism at the same time. Is there a way to accomplish that in Qt?

    Thank in advance!



  • See the QSessionManager and QApplication::commitData documentation. You could set a flag there which will lead your windows to accept the closeEvent.




Log in to reply