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 to intercept Cntrl+Alt+F1 and Cntr+Alt+Backspace ?

How to intercept Cntrl+Alt+F1 and Cntr+Alt+Backspace ?

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
embedded qteventfilter
9 Posts 4 Posters 1.3k 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.
  • P Offline
    P Offline
    prinzkm
    wrote on 9 Jul 2020, 19:10 last edited by
    #1

    I used EventFilter .Somehow I'm able to detect key event and shortcut events. But how to implement it neatly using Qt. I'm using an older version of qt.(qt 4.5.2).

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 9 Jul 2020, 19:13 last edited by
      #2

      Hi,

      AFAIR, these are system shortcuts to switch to the first tty and the other to kill the X11 session. Nothing that even reaches Qt.

      As for your Qt version, it's not just old, it's way past its death bed. If you are locked to Qt 4, then at least move to Qt 4.8.7 which is the latest and last of that series. Otherwise, please use Qt 5.

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

      P 1 Reply Last reply 9 Jul 2020, 19:20
      2
      • S SGaist
        9 Jul 2020, 19:13

        Hi,

        AFAIR, these are system shortcuts to switch to the first tty and the other to kill the X11 session. Nothing that even reaches Qt.

        As for your Qt version, it's not just old, it's way past its death bed. If you are locked to Qt 4, then at least move to Qt 4.8.7 which is the latest and last of that series. Otherwise, please use Qt 5.

        P Offline
        P Offline
        prinzkm
        wrote on 9 Jul 2020, 19:20 last edited by
        #3

        @SGaist Thank you for the info. But there should be a way to modify the default behaviour.Right?Can Signal handlers be used?Why are you recommending qt5?does it handle this event?

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 9 Jul 2020, 19:23 last edited by
          #4

          As I said, these are system shortcut that application have no access to.

          Why Qt 5 ? Because Qt 4 has reached end of life years ago already. Even more Qt 6 is around the corner.

          As already written, you are not even using the latest version of Qt 4.

          If that's not enough, you are using a version that does not have had all the bug fixes and more important security fixes that have been added through the years.

          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
          • M Offline
            M Offline
            mrjj
            Lifetime Qt Champion
            wrote on 10 Jul 2020, 14:52 last edited by
            #5

            Hi
            But does Cntrl+Alt+F1 and Cntr+Alt+Backspace work with you for your app using event filters ?

            P 1 Reply Last reply 28 Jul 2020, 17:14
            0
            • S Offline
              S Offline
              SimonSchroeder
              wrote on 13 Jul 2020, 07:08 last edited by
              #6

              Qt does not have any problem with handling Ctrl+Alt+F1 and Ctrl+Alt+Backspace. These would usually work perfectly fine on Windows systems. However, even when your application is in focus all keyboard and mouse events first go to the operating system. The operating system will then decide what to do with these. In normal circumstances it will forward everything to the currently active app. If your shortcuts are not working as expected it is most likely that you are using Linux (since you added the 'embedded' tag this is very likely). Linux as the operating system gets first dips on the shortcuts, recognizes them and applies them. Hence, there is no forwarding to your application. You would need to register your shortcuts (or rather override) with the operating system. This is outside of the scope of Qt. I am also not sure how this would work. For testing you could turn off these system shortcuts on your Linux install. However, it is better to avoid these shortcuts alltogether as they might introduce "bugs" after deployment.

              P 1 Reply Last reply 28 Jul 2020, 17:19
              2
              • M mrjj
                10 Jul 2020, 14:52

                Hi
                But does Cntrl+Alt+F1 and Cntr+Alt+Backspace work with you for your app using event filters ?

                P Offline
                P Offline
                prinzkm
                wrote on 28 Jul 2020, 17:14 last edited by
                #7

                @mrjj I intentionally filtered all events in the eventFilter function of my EventFilter(QObject Type) class and set the event filter for the qt application itself. Surprisingly, it did filter Cntrl+Alt+F1 and Cntrl+Alt+Backspace Events.(Or It didn't switch the terminal or killed itself).But I was unable to filter only these events.But From @SGaist 's reply, what I understood is it is outside the scope of Qt. I saw some solutions for X11 based system.We use frame buffers instead.Any idea ?

                1 Reply Last reply
                0
                • S SimonSchroeder
                  13 Jul 2020, 07:08

                  Qt does not have any problem with handling Ctrl+Alt+F1 and Ctrl+Alt+Backspace. These would usually work perfectly fine on Windows systems. However, even when your application is in focus all keyboard and mouse events first go to the operating system. The operating system will then decide what to do with these. In normal circumstances it will forward everything to the currently active app. If your shortcuts are not working as expected it is most likely that you are using Linux (since you added the 'embedded' tag this is very likely). Linux as the operating system gets first dips on the shortcuts, recognizes them and applies them. Hence, there is no forwarding to your application. You would need to register your shortcuts (or rather override) with the operating system. This is outside of the scope of Qt. I am also not sure how this would work. For testing you could turn off these system shortcuts on your Linux install. However, it is better to avoid these shortcuts alltogether as they might introduce "bugs" after deployment.

                  P Offline
                  P Offline
                  prinzkm
                  wrote on 28 Jul 2020, 17:19 last edited by
                  #8

                  @SimonSchroeder ![alt text](Screenshot 2020-07-28 at 10.47.49 PM.png image url)

                  This solution may work for Cntrl+Alt+Backspace.But For that driver name is required.How can I find which driver is loaded (in linux) for keyboard?

                  S 1 Reply Last reply 30 Jul 2020, 07:14
                  0
                  • P prinzkm
                    28 Jul 2020, 17:19

                    @SimonSchroeder ![alt text](Screenshot 2020-07-28 at 10.47.49 PM.png image url)

                    This solution may work for Cntrl+Alt+Backspace.But For that driver name is required.How can I find which driver is loaded (in linux) for keyboard?

                    S Offline
                    S Offline
                    SimonSchroeder
                    wrote on 30 Jul 2020, 07:14 last edited by
                    #9

                    @prinzkm I don't have any experience with Qt on embedded devices. However, on the same page you provided the screenshot it has a section on "Available Keyboard Drivers". These are Qt-specific drivers, as far as I understand. It seems that currently only two drivers are available: TTY and LinuxInput. By default Qt is only compiled with support for TTY. Unfortunately, this is also the driver which intercepts Ctrl+Alt+F1 and Ctrl+Alt+Backspace. Therefore, you should have a look at the other driver. My understanding is that for this to work you need to compile Qt yourself with the LinuxInput driver enabled (by providing the command line option -qt-kbd-linuxinput when configuring Qt before compilation. I hope, somebody else can help you with these keyboard drivers.

                    1 Reply Last reply
                    1

                    • Login

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