#include #include #include #include #include // To reproduce: // 1. Run app // 2. Close main window with close button on caption bar // 3. Try to exit via the application menu or Cmd-Q // // EXPECTED: application quits // ACTUAL: unable to quit int main(int argc, char *argv[]) { QApplication app(argc, argv); app.setQuitOnLastWindowClosed(false); // Create the global menu which we will revert to when the QMainWindow is closed QMenuBar* sharedMenuBar=new QMenuBar(0); QMenu* sharedMenu= sharedMenuBar->addMenu("Shared menu"); sharedMenu->addAction("Nop"); // Create an Exit menu item which will be moved to the application menu QAction* exitAct = sharedMenu->addAction("E&xit"); exitAct->setMenuRole(QAction::QuitRole); sharedMenu->addAction(exitAct); // Workaround is to uncomment the following line: // QObject::connect(exitAct, SIGNAL(triggered()), &app, SLOT(quit())); // Now create the main window and create a simple menu for it QMainWindow mainWindow; QLabel* staticText=new QLabel("Hit the close button to close this window then type cmd-Q"); mainWindow.setCentralWidget(staticText); QMenu* mainWindowFileMenu= mainWindow.menuBar()->addMenu("Window menu"); mainWindowFileMenu->addAction("Nop"); mainWindow.show(); return app.exec(); }