I created the shortcut events, such as:
new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q), this, SLOT(close()));
But now I would like to show "Ctrl+Q" in the menu entry here:
How do I do that? I don't seem to find a way to do that in Qt Creator.
I created the shortcut events, such as:
new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q), this, SLOT(close()));
But now I would like to show "Ctrl+Q" in the menu entry here:
How do I do that? I don't seem to find a way to do that in Qt Creator.
You can set the shortcut keys in the QtDesigner in the 'Action Editor' (Tab at the bottom, the 'Signal/Slot Editor' tab is selected by default).
Here all defined QActions are listed. A double click on a field in the 'shortcut' column will open the wanted dialog.
This will add the shortcut to the QAction (create triggered events) and set it as visibile text, e.g. in the menu entry (only visible in the application, not in QtDesigner).
In the 'Property Editor' are more options for the 'shortcuts' (e.g. make them translatable).
Generally you would use
QAction
class for this, so you would have aQMenu
to which you will add actions, in your caseCLOSE
. Then you can useSetShortcut
to add"CTRL + Q"
in menu.where
pNewAction
is of typeQAction
.