Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED] keyPressEvent Qt_Key doesn't work
Qt 6.11 is out! See what's new in the release blog

[SOLVED] keyPressEvent Qt_Key doesn't work

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 2.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    I have the keyPressEvent method and inside I have something like that:

    @if (event->key() == Qt::Key_Up) {
    qDebug() << "up key";
    } else if (event->modifiers().testFlag(Qt::AltModifier) && event->key() == Qt::Key_Enter) {
    qDebug() << "ctrl+enter"
    }@

    But doesn't work. Other keys works normally, but keys like Ctrl, Alt, Shift, Enter, and so on, doesn't.

    Enter key works only when I put 16777220 instead of Qt_Key_Enter

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Are you sure it's not Qt::Key_Return that you want to use ? AFAIK, Key_Enter is for the keypad "Return"

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #3

        Thanks, it's working.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          You're welcome !

          Since your keys are working now, please update the thread title prepending [solved] so other forum users may know solution has been found :)

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt
          • Unsolved