How to activate QActions from keypresses?
kitfox last edited by kitfox
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?
JonB last edited by
ValentinMichelet last edited by
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");