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. How can I grab keyboard input event without showing widget?
Forum Updated to NodeBB v4.3 + New Features

How can I grab keyboard input event without showing widget?

Scheduled Pinned Locked Moved Mobile and Embedded
5 Posts 2 Posters 3.5k Views 2 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.
  • S Offline
    S Offline
    Sung Sean
    wrote on 16 Jul 2015, 09:30 last edited by
    #1

    Hello.

    I using Qt 4.8.3 + DirectFB on embedded system(ARM-Core).

    When I run my application, that has QMainApplication and widgets.
    But all widgets are hiding.

    I want to show widgets when I push keyboard.
    At this time, how can I grab keyboard input on QMainApplication?

    Thank you.

    1 Reply Last reply
    0
    • C Offline
      C Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on 16 Jul 2015, 10:16 last edited by
      #2

      There's no QMainApplication class in Qt.

      You can intercept all the app keyboard in a couple of ways.
      One of them is installing an event filter on the qApp object and fishing for QEvent::KeyPress there.

      S 1 Reply Last reply 16 Jul 2015, 10:47
      0
      • C Chris Kawa
        16 Jul 2015, 10:16

        There's no QMainApplication class in Qt.

        You can intercept all the app keyboard in a couple of ways.
        One of them is installing an event filter on the qApp object and fishing for QEvent::KeyPress there.

        S Offline
        S Offline
        Sung Sean
        wrote on 16 Jul 2015, 10:47 last edited by
        #3

        @Chris-Kawa
        Thank you for reply.
        I made mistake. I mean QApplication, not QMainApplication.

        So, I using test code like below link.
        http://www.codeprogress.com/cpp/libraries/qt/showQtExample.php?key=QApplicationInstallEventFilter&index=188

        When I call "main.show()", then eventFilter-KeyPress- working well.
        But delete "main.show()", then eventFilter-KeyPress not triggered.

        Is there no way grab keyboard input without showing widget?

        Thank you.

        1 Reply Last reply
        0
        • C Offline
          C Offline
          Chris Kawa
          Lifetime Qt Champion
          wrote on 16 Jul 2015, 11:04 last edited by
          #4

          Oh, I misunderstood then.
          Qt can only expose events it receives from the OS. An app that does not have any windows does not receive any keyboard events from OS.

          For that you would have to hook into the keyboard events directly, which is highly platform specific and beyond what Qt provides.
          You might look into 3rd party libraries for this functionality, for example QxtGlobalShortcut, but you'd have to check if it's available for your target platform.

          S 1 Reply Last reply 16 Jul 2015, 13:02
          1
          • C Chris Kawa
            16 Jul 2015, 11:04

            Oh, I misunderstood then.
            Qt can only expose events it receives from the OS. An app that does not have any windows does not receive any keyboard events from OS.

            For that you would have to hook into the keyboard events directly, which is highly platform specific and beyond what Qt provides.
            You might look into 3rd party libraries for this functionality, for example QxtGlobalShortcut, but you'd have to check if it's available for your target platform.

            S Offline
            S Offline
            Sung Sean
            wrote on 16 Jul 2015, 13:02 last edited by
            #5

            @Chris-Kawa
            I add a widget that always showing in geometry(0,0,1,1).
            This widget grab keyboard input and pass to QApplication.
            It not perfect but looks okay for my target platform :-).

            Thank you for kind reply and have a good day.

            1 Reply Last reply
            0

            1/5

            16 Jul 2015, 09:30

            • Login

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