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. Keys.onReleased Premature trigger

Keys.onReleased Premature trigger

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 584 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.
  • TrayonT Offline
    TrayonT Offline
    Trayon
    wrote on last edited by
    #1

    I wanted to look into the QML key capturing mechanism, but immediately found a problem with it. If I keep either key pressed, it continues to register the event. Even if I just keep the right key pressed, and hence never released, it keeps triggering.

        Item {
            focus: true
            Keys.onPressed: {
                if (event.key == Qt.Key_Left) {
                    console.log("press left");
                    event.accepted = true;
                }
            }
            Keys.onReleased: {
                if (event.key == Qt.Key_Right) {
                    console.log("release right");
                    event.accepted = true;
                }
            }
            Keys.onReturnPressed: console.log("Pressed return");
        }
    
    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      Its the auto repeat feature.
      In c++ you check if QKeyEvent::isAutoRepeat()
      to filter out if unwanted.
      I have no idea with QML :)

      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