I'm adding a bunch of QAction
s to my main window's menus. These actions can also be triggered by the keyboard, and I want the shortcut to be visible in the menu, as usual, e.g.
-----------------
|Copy Ctrl+C|
-----------------
I can do this using QAction.setShortcut()
. However, I don't want these QAction
s to be triggered by the shortcuts; I'm handling all keyboard input separately elsewhere.
Is this possible? Can I disable the shortcut in the QAction but still have the shortcut text (in this example "Ctrl+C") in my menus?
EDIT: The way I ended up doing it is connecting to the menu's aboutToShow()
and aboutToHide()
events, and enabling/disabling the shortcuts so they are only active when the menu is shown. But I'd appreciate a cleaner solution...