<div dir="ltr"><div><div><div><div><div><div>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<br><br></div>    def closeEvent(self, event):<br></div>        # save stuff in settings...<br></div>        event.accept()<br></div>        super().closeEvent(event)<br><br></div>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.<br><br></div><div>I tried with and without the event.accept() and with and without the call to the super's method. The behavior didn't change.<br><br></div>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?<br><br><div><div><div><div><div><div>Thanks,<br>Dave Cortesi<br><br>[1] <a href="http://doc.qt.io/qt-5/qmainwindow.html#saveState">http://doc.qt.io/qt-5/qmainwindow.html#saveState</a><br></div></div></div></div></div></div></div>