Important: Please read the Qt Code of Conduct -

QKeyEvent key as string

  • Hello,

    I'm looking for an option to show a user his assigned keys.
    The problem is to get a string of the key values, like Qt::CTRL to "Ctrl" or Qt::ALT to "Alt".
    event->key() correctly gets the value, but event event->text() work only for characters, not for CTRL, ALT, etc..

  • Probably, this may help.

    enum Qt::KeyboardModifier contains only 7 values. Analyze the QKeyEvent::modifiers() and append the corresponding string.

Log in to reply