How to activate QActions from keypresses?
-
Does Qt have an API feature for activating QActions when certain keys are pressed, or does each widget need to do this independently via the keyPressEvent()? I know that Java's Swing API has a keymap feature that handles this and was wondering if Qt had something similar.
In other words - what's the recommended way to have something like Ctrl-V activate a Paste action?
-
Does Qt have an API feature for activating QActions when certain keys are pressed, or does each widget need to do this independently via the keyPressEvent()? I know that Java's Swing API has a keymap feature that handles this and was wondering if Qt had something similar.
In other words - what's the recommended way to have something like Ctrl-V activate a Paste action?
-
To complete JonB’s answer, you have several ways to specify a shortcut for an action:
action->setShortcut(QKeySequence::Copy); action->setShortcut(QKeySequence(Qt::CTRL+Qt::key_v)); action->setShortcut(QKeySequence("CTRL+V");