Qt Forum

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

    Update: Forum Guidelines & Code of Conduct

    Unsolved Keys.onReleased Premature trigger

    General and Desktop
    2
    2
    247
    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.
    • Trayon
      Trayon last edited by

      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 Reply Quote 0
      • mrjj
        mrjj Lifetime Qt Champion last edited by

        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 Reply Quote 1
        • First post
          Last post