I put on multiple shortcuts on each QAction
, e.g. 'L, Right, Space'.
but 'L' shortcut doesn't now work. 'Right' and 'Space' can work.
Similarly, if I register 'A, B' and then, 'A' will not work and 'B' will work.
If I use QMainWindow::eventFilter()
myself, instead of using QAction::setShortcut()
, all shortcut keys will work.
In this case, of course, the shortcut key text is not displayed on the main menu.
I tested on Windows 7 x64, and Qt-5.9.1
QMap<QString, QAction*>& actions = qApp->keyActions().actions();
QMap<QString, QKeySequence> & seqMap = qApp->keyActions().keyMaps();
foreach(const QString& name, actions.keys()) {
QAction* a = actions[name];
QKeySequence seq = seqMap[name]; // e.g. QKeySequence("L, Right, Space")
a->setShortcut(seq);
a->setShortcutContext(Qt::ApplicationShortcut);
}