Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. QKeyEvent configuration

QKeyEvent configuration

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
6 Posts 3 Posters 1.9k Views
  • 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.
  • radioraheemR Offline
    radioraheemR Offline
    radioraheem
    wrote on last edited by
    #1

    I have a question about QKeyEvents. I've inherited an embedded application which makes use of an eventFilter to look for input from the device's 4 directional keypad:

    bool KeyPressEater::eventFilter(QObject *obj, QEvent *event)
    {
        if (event->type() == QEvent::KeyPress) {
            QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
    
            switch ( keyEvent->key() )
            {
                case Qt::Key_Up:
                    emit UpKey(obj);
                    break;
                case Qt::Key_Down:
                    emit DownKey(obj);
                    break;
                case Qt::Key_Left:
                    emit LeftKey(obj);
                    break;
                case Qt::Key_Right:
                    emit RightKey(obj);
                    break;
                case Qt::Key_Q:
                    emit QKey(obj);
                    break;
                default:
                    break;
            }
            return true;
        } 
        else
            return QObject::eventFilter(obj, event);
    }
    

    Which all works well. I need to know how QT is configured to use the keypad - how does QT know that when a particular button is pressed that it is the the Qt::Key_Left or Qt::Key_Right key?

    Can anyone point me in the right direction to find out how this is configured?

    Thanks!

    raven-worxR 1 Reply Last reply
    0
    • radioraheemR radioraheem

      I have a question about QKeyEvents. I've inherited an embedded application which makes use of an eventFilter to look for input from the device's 4 directional keypad:

      bool KeyPressEater::eventFilter(QObject *obj, QEvent *event)
      {
          if (event->type() == QEvent::KeyPress) {
              QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
      
              switch ( keyEvent->key() )
              {
                  case Qt::Key_Up:
                      emit UpKey(obj);
                      break;
                  case Qt::Key_Down:
                      emit DownKey(obj);
                      break;
                  case Qt::Key_Left:
                      emit LeftKey(obj);
                      break;
                  case Qt::Key_Right:
                      emit RightKey(obj);
                      break;
                  case Qt::Key_Q:
                      emit QKey(obj);
                      break;
                  default:
                      break;
              }
              return true;
          } 
          else
              return QObject::eventFilter(obj, event);
      }
      

      Which all works well. I need to know how QT is configured to use the keypad - how does QT know that when a particular button is pressed that it is the the Qt::Key_Left or Qt::Key_Right key?

      Can anyone point me in the right direction to find out how this is configured?

      Thanks!

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by raven-worx
      #2

      @radioraheem said:

      Which all works well. I need to know how QT is configured to use the keypad - how does QT know that when a particular button is pressed that it is the the Qt::Key_Left or Qt::Key_Right key?

      Can anyone point me in the right direction to find out how this is configured?

      Qt processes the platform events/messages in the Qt platform plugin and translates them to Qt events.
      So probably your keypad's driver reacts on presses and it's driver forwards the events to the system which then forwards to Qt.

      Is that the information you requested?

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      radioraheemR 1 Reply Last reply
      2
      • raven-worxR raven-worx

        @radioraheem said:

        Which all works well. I need to know how QT is configured to use the keypad - how does QT know that when a particular button is pressed that it is the the Qt::Key_Left or Qt::Key_Right key?

        Can anyone point me in the right direction to find out how this is configured?

        Qt processes the platform events/messages in the Qt platform plugin and translates them to Qt events.
        So probably your keypad's driver reacts on presses and it's driver forwards the events to the system which then forwards to Qt.

        Is that the information you requested?

        radioraheemR Offline
        radioraheemR Offline
        radioraheem
        wrote on last edited by
        #3

        Thanks, @raven-worx - that is the type of info I was after.

        Do you know where exactly the translation to QT events takes place? (You say "in the Qt platform plugin", but is there a config file or something for building this mapping, or something else?)

        I'm working on an open-embedded based system and can see where the keypresses are translated by device tree's GPIO multiplexing but wanted to trace the signal paths through from there to QT...

        Thnaks,

        Iain

        raven-worxR kshegunovK 2 Replies Last reply
        0
        • radioraheemR radioraheem

          Thanks, @raven-worx - that is the type of info I was after.

          Do you know where exactly the translation to QT events takes place? (You say "in the Qt platform plugin", but is there a config file or something for building this mapping, or something else?)

          I'm working on an open-embedded based system and can see where the keypresses are translated by device tree's GPIO multiplexing but wanted to trace the signal paths through from there to QT...

          Thnaks,

          Iain

          raven-worxR Offline
          raven-worxR Offline
          raven-worx
          Moderators
          wrote on last edited by
          #4

          @radioraheem
          no i can't tell you where to look exactly, would have to take a look myself.
          But you can either way try to set a breakpoint in a keyevent handler in one of your widgets (only when the keyevent wasn't posted to the eventloop by the platform plugin) or you start digging in the source code of the platform plugin of your corresponding system.

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

          1 Reply Last reply
          0
          • radioraheemR radioraheem

            Thanks, @raven-worx - that is the type of info I was after.

            Do you know where exactly the translation to QT events takes place? (You say "in the Qt platform plugin", but is there a config file or something for building this mapping, or something else?)

            I'm working on an open-embedded based system and can see where the keypresses are translated by device tree's GPIO multiplexing but wanted to trace the signal paths through from there to QT...

            Thnaks,

            Iain

            kshegunovK Offline
            kshegunovK Offline
            kshegunov
            Moderators
            wrote on last edited by kshegunov
            #5

            @radioraheem said:

            Do you know where exactly the translation to QT events takes place? (You say "in the Qt platform plugin", but is there a config file or something for building this mapping, or something else?)

            It's spread over multiple files and done in multiple stages. You could start by looking at the window system interface class.
            Here:
            http://code.qt.io/cgit/qt/qtbase.git/tree/src/gui/kernel/qwindowsysteminterface.cpp
            http://code.qt.io/cgit/qt/qtbase.git/tree/src/gui/kernel/qwindowsysteminterface.h
            http://code.qt.io/cgit/qt/qtbase.git/tree/src/gui/kernel/qwindowsysteminterface_p.h

            There's also some code in the platform plugins:
            http://code.qt.io/cgit/qt/qtbase.git/tree/src/platformsupport/input

            Kind regards.

            Read and abide by the Qt Code of Conduct

            radioraheemR 1 Reply Last reply
            1
            • kshegunovK kshegunov

              @radioraheem said:

              Do you know where exactly the translation to QT events takes place? (You say "in the Qt platform plugin", but is there a config file or something for building this mapping, or something else?)

              It's spread over multiple files and done in multiple stages. You could start by looking at the window system interface class.
              Here:
              http://code.qt.io/cgit/qt/qtbase.git/tree/src/gui/kernel/qwindowsysteminterface.cpp
              http://code.qt.io/cgit/qt/qtbase.git/tree/src/gui/kernel/qwindowsysteminterface.h
              http://code.qt.io/cgit/qt/qtbase.git/tree/src/gui/kernel/qwindowsysteminterface_p.h

              There's also some code in the platform plugins:
              http://code.qt.io/cgit/qt/qtbase.git/tree/src/platformsupport/input

              Kind regards.

              radioraheemR Offline
              radioraheemR Offline
              radioraheem
              wrote on last edited by
              #6

              @kshegunov That's exactly what I was after - thanks!

              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 Extensions
              • Unsolved