Details
-
Bug
-
Resolution: Done
-
P3: Somewhat important
-
4.7.1
-
None
Description
On Windows and Mac with non native menu bar, the QMenu::triggered signal is not emitted - as expected.
On Mac when using the native menu bar, QMenu::triggered is triggered - not expected
Example to reproduce the issue:
#include <QtGui> class Window : public QMainWindow { Q_OBJECT public: Window() { menuBar()->setNativeMenuBar(true); QMenu* menu = new QMenu("Menu"); QMenu* subMenu = new QMenu("SubMenu"); menu->addMenu(subMenu);//->setProperty("toignore", true); menu->addAction("Item2"); connect(menu, SIGNAL(triggered(QAction*)), this, SLOT(onMenuBarTriggered(QAction*))); menuBar()->addMenu(menu); } public slots: void onMenuBarTriggered(QAction* action) { //if (!action->property("toignore").toBool()) QMessageBox::information(this, "Menu triggered", action->text()); } }; int main(int argc, char* argv[]) { QApplication app(argc, argv); Window* w = new Window; w->show(); return app.exec(); } #include "main.moc"
Suggested workaround:
Setting a property to be able to ignore the code when the slot is triggered
Tested with Cocoa
Attachments
For Gerrit Dashboard: QTBUG-16738 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
23169,2 | Do not set an action on native submenu items on Mac | master | qt/qtbase | Status: MERGED | +2 | 0 |