Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Unsolved qkeyevent Ignore modifiers

    General and Desktop
    3
    9
    1294
    Loading More Posts
    • 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.
    • Megamouse
      Megamouse last edited by Megamouse

      How can i ignore modifiers and only show the actual key that was pressed?

      E.g. I don't want to get the key for ( when I press shift+8 on a german layout. I want the key for 8.

      edit: It would also be okay if I could simply disable the modifiers completely

      jsulm 1 Reply Last reply Reply Quote 0
      • jsulm
        jsulm Lifetime Qt Champion @Megamouse last edited by

        @Megamouse Why don't you simply check http://doc.qt.io/qt-5/qkeyevent.html#modifiers? See http://doc.qt.io/qt-5/qt.html#KeyboardModifier-enum

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        Megamouse 1 Reply Last reply Reply Quote 2
        • Megamouse
          Megamouse @jsulm last edited by

          @jsulm I'm sorry but this isn't helpful at all

          JonB 1 Reply Last reply Reply Quote 0
          • JonB
            JonB @Megamouse last edited by

            @Megamouse
            If you want to just know which key is pressed, look at http://doc.qt.io/qt-5/qkeyevent.html#key member function. Unlike http://doc.qt.io/qt-5/qkeyevent.html#text, the former gives the raw key, without applying modifiers to generate the corresponding Unicode character.

            Megamouse 1 Reply Last reply Reply Quote 2
            • Megamouse
              Megamouse @JonB last edited by

              @JonB key() returns different codes for let's say... 1 and shift+1 (namely ! on german keyboards).
              but I need the same value regardless of the shift

              JonB 1 Reply Last reply Reply Quote 0
              • JonB
                JonB @Megamouse last edited by

                @Megamouse
                From the docs, I would have expected http://doc.qt.io/qt-5/qkeyevent.html#key to return Qt::Key_1 (http://doc.qt.io/qt-5/qt.html#Key-enum) in both cases. What do they each return?

                Megamouse 1 Reply Last reply Reply Quote 0
                • Megamouse
                  Megamouse @JonB last edited by

                  @JonB Key_1 and Key_Exclam

                  JonB 2 Replies Last reply Reply Quote 1
                  • JonB
                    JonB @Megamouse last edited by

                    @Megamouse That's a bit of a blow, then! :(

                    1 Reply Last reply Reply Quote 0
                    • JonB
                      JonB @Megamouse last edited by JonB

                      @Megamouse
                      Then I think you'll have to go down to the level of http://doc.qt.io/qt-5/qkeyevent.html#nativeScanCode

                      Don't ask me where you look up its return values though, as I don't know that!

                      And if that doesn't work, and you/I don't see another method to get at raw keyboard keys, I can only see that you'll have to write a large switch...case statement on QKeyEvent::key() for your keyboard!

                      1 Reply Last reply Reply Quote 0
                      • First post
                        Last post