Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to add keys to QT which doesn't support
Forum Update on Monday, May 27th 2025

How to add keys to QT which doesn't support

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 860 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.
  • A Offline
    A Offline
    Alien
    wrote on 22 Feb 2019, 06:48 last edited by
    #1

    Hello,

    I'm curious about keys which didn't define in qt event keys, some keys defined like Key_VolumeUp/Down and a lot more but some keys like brightness up/down didn't define in Qt in this case for example linux sends key event of that key which didn't define in qt so I can't get the key.

    Is it possible to add some keys into qt without modifing and compiling QT source?
    Please let me know if you have any other solutions about this issue.

    I appreciate any idea

    Yours,
    Alien

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SamurayH
      wrote on 22 Feb 2019, 19:47 last edited by SamurayH
      #2

      Hi @Alien,
      The QKeyEvent class has a method for you: nativeVirtualKey, that returns the native virtual key (the one sent by linux).

      So if you want to get those brightness keys, you must search for their natives codes. I'm not using linux, but it seems to be these ones :

      #define KEY_BRIGHTNESSDOWN	224
      #define KEY_BRIGHTNESSUP	225
      

      So now, in your key press event handler, it could be something like :

      void YourWidget::keyPressEvent(QKeyEvent *event){
          if(event->nativeVirtualKey() == KEY_BRIGHTNESSDOWN)
              // brightness down
          else if(event->nativeVirtualKey() == KEY_BRIGHTNESSUP)
              // brightness up
      //...
      }
      

      Hope it helps.

      "قال رسول الله صلى الله عليه وسلم : " أحب الناس إلى الله أنفعهم للناس

      1 Reply Last reply
      4
      • A Offline
        A Offline
        Alien
        wrote on 24 Feb 2019, 16:33 last edited by
        #3

        Dear @SamurayH ,

        When there is no key defined in qt therefore there is no event for that!
        I implement an application and put your suggested code inside it when my keyboard driver send undefined key to application it can't get related event in qt so I'm not able to handle it.

        Thanks for your reply but it doesn't work!

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 24 Feb 2019, 19:02 last edited by
          #4

          Hi,

          I would go with a QAbstractNativeEventFilter.

          That should give you access to the events you are looking for.

          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
          2

          1/4

          22 Feb 2019, 06:48

          • Login

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