Nominate our 2022 Qt Champions!

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?

  • @kitfox
    QActions can have "shortcut keys" associated with them. See So the action holds what key activates it for you.

  • To complete JonB’s answer, you have several ways to specify a shortcut for an action:


Log in to reply