Details
-
Bug
-
Resolution: Done
-
P1: Critical
-
6.0.0
-
None
-
Arch Linux
-
-
e7370d0583ea8a50b0d5c15bb2b1afee2efc6a7e (qt/qtbase/dev) 254aa011b1a783d29db542ed9450be333b943133 (qt/qtbase/6.0)
Description
Calling QApplication::quit() from within a widget's closeEvent() no longer has any effect in Qt 6.0.0.
The test case below, with Qt 5, quits when the window is closed. In Qt 6, QApplication::exec() does not return and the application remains running with no windows visible.
Note: It's necessary to do setQuitOnLastWindowClosed(false) to see the issue (otherwise the application quits regardless of QApplication::quit() being called or not).
Test case:
#include <QApplication> #include <QCloseEvent> #include <QWidget> class MyWindow : public QWidget { public: void closeEvent(QCloseEvent * event) override { qApp->quit(); event->accept(); } }; int main(int argc, char ** argv) { QApplication app(argc, argv); app.setQuitOnLastWindowClosed(false); MyWindow window; window.show(); return app.exec(); }