Details
-
Bug
-
Resolution: Done
-
P2: Important
-
5.1.0 , 5.2.1, 5.3.1
-
Mac OS X 10.9
-
-
412ec70f14aa0c966d13481a35c498e6c905dec3, 22afbc153628348bc6d4ee0655ea6a6584a13322
Description
Set QAction shortcut to plain letter "i" and it doesn't trigger on Mac. It works on Qt 4.8 and Qt 5.0.2. Only Mac issue.
Workaround is to use QShortcut instead of QAction or trigger QAction from QShortcut like example below:
#include <QtWidgets> int main(int argc, char *argv[]) { QApplication a(argc, argv); QMainWindow mainWindow; QMenu* menu = new QMenu("&Zoom",&mainWindow); QAction* zoomInAction = new QAction("Zoom &in", &mainWindow); zoomInAction->setShortcut(QKeySequence("i")); QObject::connect(zoomInAction, SIGNAL(triggered()), &mainWindow, SLOT(showMaximized())); menu->addAction(zoomInAction); QAction* zoomOutAction = new QAction("Zoom &Out", &mainWindow); zoomOutAction->setShortcut(QKeySequence("o")); QObject::connect(zoomOutAction, SIGNAL(triggered()), &mainWindow, SLOT(showNormal())); menu->addAction(zoomOutAction); //// WORKAROUND //#ifdef Q_OS_MAC // QObject::connect(new QShortcut(zoomInAction->shortcut(),zoomInAction->parentWidget()), // SIGNAL(activated()), zoomInAction, SLOT(trigger())); // QObject::connect(new QShortcut(zoomOutAction->shortcut(),zoomOutAction->parentWidget()), // SIGNAL(activated()), zoomOutAction, SLOT(trigger())); //#endif mainWindow.menuBar()->addMenu(menu); mainWindow.show(); return a.exec(); }
Could this cause the issue?
https://bugreports.qt-project.org/browse/QTBUG-30695
https://codereview.qt-project.org/#change,54652
Attachments
Issue Links
- relates to
-
QTBUG-44987 OS X: QAction in the shared or global menubar was not triggered
-
- Reported
-
- replaces
-
QTBUG-38976 Shortcuts don't trigger actions in some cases
-
- Closed
-