[PyQt] closeEvent called twice?
David Cortesi
davecortesi at gmail.com
Wed May 11 00:10:09 BST 2016
I have a basically straightforward app built around a QMainWindow. I have
implemented the closeEvent() method to save various things such as the
window geometry, as suggested in the QMainWindow doc[1]. The logic is
basically
def closeEvent(self, event):
# save stuff in settings...
event.accept()
super().closeEvent(event)
This code is executed TWICE when the main window is closed. Both times
apparently directly from the QApplication. I have run this under an IDE
with a debug stop on the statement following the app.exec_() call, so I am
sure this is happening after the File>Quit is issued, but before the app
returns control to my main code.
I tried with and without the event.accept() and with and without the call
to the super's method. The behavior didn't change.
It does no harm to save the settings twice, but it annoys me. Can anyone
speculate why the app would call the main window closeEvent twice?
Thanks,
Dave Cortesi
[1] http://doc.qt.io/qt-5/qmainwindow.html#saveState
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20160510/1a406a32/attachment.html>
More information about the PyQt
mailing list