-
Bug
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
4.6.2, 4.6.3, 4.7.0
-
None
-
Snow Leopard cocoa build.
When the quit action is disabled in a Qt cocoa application it is still possible to quit the Qt application by right clicking on the dock icon, or closing the window when app.setQuitOnLastWindowClosed is not set.
#include <QtGui> class MyWidget: public QWidget { Q_OBJECT public: MyWidget(QWidget *parent = 0); private slots: void doSomething(); void quitActionCalled(); private: QHBoxLayout *layout; QPushButton *button; QMenuBar *menuBar; QAction *quitAction; }; MyWidget::MyWidget(QWidget *parent) : QWidget(parent) { setWindowTitle("Support Tester"); layout = new QHBoxLayout; button = new QPushButton ("toggle quit state"); layout->addWidget(button); setLayout(layout); menuBar = new QMenuBar(0); QMenu *menu = menuBar->addMenu("testMenu"); quitAction = menu->addAction("Quit",this,SLOT(quitActionCalled())); QObject::connect(button, SIGNAL(clicked()), this, SLOT(doSomething())); } void MyWidget::quitActionCalled() { qDebug("quit"); } void MyWidget::doSomething() { if (quitAction->isEnabled()) { quitAction->setEnabled(false); } else { quitAction->setEnabled(true); } qDebug("quit state toggled"); } //This moc include is to get everything in a single file - for quick testing only #include "main.moc" int main(int argc, char *argv[]) { QApplication app(argc, argv); MyWidget *myWin = new MyWidget(); // app.setQuitOnLastWindowClosed(false); myWin->show(); return app.exec(); }