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
Forum Updated to NodeBB v4.3 + New Features

QKeyEvent configuration

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
6 Posts 3 Posters 1.9k 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.
  • R Offline
    R Offline
    radioraheem
    wrote on 23 May 2016, 03:51 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!

    R 1 Reply Last reply 23 May 2016, 06:24
    0
    • R radioraheem
      23 May 2016, 03:51

      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!

      R Offline
      R Offline
      raven-worx
      Moderators
      wrote on 23 May 2016, 06:24 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

      R 1 Reply Last reply 24 May 2016, 02:42
      2
      • R raven-worx
        23 May 2016, 06:24

        @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?

        R Offline
        R Offline
        radioraheem
        wrote on 24 May 2016, 02:42 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

        R K 2 Replies Last reply 24 May 2016, 05:32
        0
        • R radioraheem
          24 May 2016, 02:42

          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

          R Offline
          R Offline
          raven-worx
          Moderators
          wrote on 24 May 2016, 05:32 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
          • R radioraheem
            24 May 2016, 02:42

            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

            K Offline
            K Offline
            kshegunov
            Moderators
            wrote on 24 May 2016, 12:15 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

            R 1 Reply Last reply 25 May 2016, 00:53
            1
            • K kshegunov
              24 May 2016, 12:15

              @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.

              R Offline
              R Offline
              radioraheem
              wrote on 25 May 2016, 00:53 last edited by
              #6

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

              1 Reply Last reply
              0

              3/6

              24 May 2016, 02:42

              • Login

              • Login or register to search.
              3 out of 6
              • First post
                3/6
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved