Details
-
Bug
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
5.12.2
-
None
-
Ubuntu 19.04 on Intel.
Description
It is possible to make shortcuts visible in a custom context menu (QMenu), but you cannot trigger the actions:
m_copyNodeAction = new QAction(tr("Copy node"), &m_mainContextMenu); m_copyNodeAction->setShortcut(QKeySequence("Ctrl+C")); m_copyNodeAction->setShortcutVisibleInContextMenu(true); m_mainContextMenu.addAction(m_copyNodeAction); QObject::connect(m_copyNodeAction, &QAction::triggered, [this] () { std::cout << "Copy node triggered!" << std::endl; });
This just doesn't work although the menu appears correctly. Calling QAction::setShortcutContext() doesn't change anything.
See also discussion on Stackoverflow:
https://stackoverflow.com/questions/57190360/how-to-make-shortcuts-trigger-in-a-custom-qmenu