[Interest] Qt5: How to detect difference between window closing and application quitting.

Michael Jackson imikejackson at gmail.com
Sat Apr 4 22:12:14 CEST 2015


I have a QMainWindow derived application on OS X (10.8.5 if is matters). This app was ported from Qt4 to Qt5 and now I seem to have an issue with my closeEven(..) being called twice. I have implemented the closeEvent(QCloseEvent* event) to capture when the window is closing so that I can call some clean up routines (Writing of settings files mainly). What I have discovered is that if I click the "red" close button this function gets called once. If I right-click on the Application in the OS X Dock then the function is called twice. I am not sure how to tell the difference between the 2 invocations. I could put in a simple counter and if it is greater than 1 then don't do the cleanup and file writing but this seems really bad. 

 Any advice is greatly appreciated.

Thanks
Mike Jackson




More information about the Interest mailing list