Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. keyevent qml overriding
Qt 6.11 is out! See what's new in the release blog

keyevent qml overriding

Scheduled Pinned Locked Moved Solved QML and Qt Quick
5 Posts 4 Posters 2.2k 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.
  • A Offline
    A Offline
    AYYAPPA
    wrote on last edited by
    #1

    hello,

    i want to override the functionality of keyevents when a key is pressed.

    i am using both custom touch keypad and physical keyboard for text entering in a TextField item.
    my code:

                Keys.onPressed: {
                    if (event.key === Qt.Key_A) KbrdCntrl.charPressed("A");
                }
    

    when i press key "A" using physical keyboard "AA" is displayed in TextField.
    one "A" from physical keyboard and another form the signal i am emitting "kbrdCntrl.charPressed("A")" .
    i want to disable the Physical keyboard's "A" . so that only one "A" will be displayed in TextField when i press "A" on physical keyboard.

    thanks.

    J.HilkJ 1 Reply Last reply
    0
    • A AYYAPPA

      hello,

      i want to override the functionality of keyevents when a key is pressed.

      i am using both custom touch keypad and physical keyboard for text entering in a TextField item.
      my code:

                  Keys.onPressed: {
                      if (event.key === Qt.Key_A) KbrdCntrl.charPressed("A");
                  }
      

      when i press key "A" using physical keyboard "AA" is displayed in TextField.
      one "A" from physical keyboard and another form the signal i am emitting "kbrdCntrl.charPressed("A")" .
      i want to disable the Physical keyboard's "A" . so that only one "A" will be displayed in TextField when i press "A" on physical keyboard.

      thanks.

      J.HilkJ Online
      J.HilkJ Online
      J.Hilk
      Moderators
      wrote on last edited by
      #2

      @AYYAPPA hi, you'll have to accept the keyevent or other wise it wil be passed on

      event.accepted = true;
      

      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


      Q: What's that?
      A: It's blue light.
      Q: What does it do?
      A: It turns blue.

      1 Reply Last reply
      0
      • A Offline
        A Offline
        AYYAPPA
        wrote on last edited by
        #3

        @J-Hilk brilliant !! thanks :)

        1 Reply Last reply
        0
        • Pablo J. RoginaP Offline
          Pablo J. RoginaP Offline
          Pablo J. Rogina
          wrote on last edited by
          #4

          @AYYAPPA if you issue is solved, please don't forget to mark your post as such. Thanks.

          Upvote the answer(s) that helped you solve the issue
          Use "Topic Tools" button to mark your post as Solved
          Add screenshots via postimage.org
          Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

          1 Reply Last reply
          0
          • D Offline
            D Offline
            dokif
            wrote on last edited by
            #5

            Hi,
            i have the same problem, but with tab and arrows keys. When i press tab for example, focus changes to next item. I need to override it, but i cannot find how. Letters, numbers, etc are beeing overriden fine, just navigations keys don't work.

            1 Reply Last reply
            0

            • Login

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