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. [Solved]get Keyboard's push and hold time duration seems impossible

[Solved]get Keyboard's push and hold time duration seems impossible

Scheduled Pinned Locked Moved QML and Qt Quick
4 Posts 2 Posters 4.2k 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.
  • C Offline
    C Offline
    cokefish
    wrote on last edited by
    #1
    • I am working on Qt 4.7.4 using QML to do a keyboard push-and-hold triggered event,

    What I am wanting to do is,

    if I push a key on keyboard for 5 second, some event should be triggered(for example, prompt a dialogbox),
    
    if the duration does not reach to 5 second, nothing should do.
    

    But I think the QML might not be available to grasp the time duration of keyboard pushing,

    When I pushed the keyboard(For example, digit 7 above character Y and U),
    held for a little while(for example 5 second),
    then released the keyboard.

    what I got were not just one events group of
    Keys.onPressed -> (about 5000 ms period) -> Keys.onReleased
    but rather endless events group of even though I had never release the keyboard at all during that period
    Keys.onPressed -> (about 30ms period) -> Keys.onReleased

    It seems that impossible to do a keyboard push-and-hold triggered event.

    Is it a bug of QML?

    1 Reply Last reply
    0
    • C Offline
      C Offline
      cokefish
      wrote on last edited by
      #2

      I found that in the signal properties, QML KeyEvent Element.
      There is a read only property of isAutoRepeat,

      when I do a fast keyboard press-release action, the isAutoRepeat will be false

      when I do a slow keyboard press-release action,
      in the endless isAutoRepeat, the first one will be false, and the others all be true, and the last one false

      is it the reason?

      1 Reply Last reply
      0
      • M Offline
        M Offline
        mlong
        wrote on last edited by
        #3

        bq. is it the reason?

        Yes. The isAutoRepeat property is used to indicate that the keypress event is occurring due to an autorepeating key. You can use this property to decide whether or not to ignore the keypress event.

        Software Engineer
        My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

        1 Reply Last reply
        0
        • C Offline
          C Offline
          cokefish
          wrote on last edited by
          #4

          OK, Thank you very much.
          Your response is just in time.

          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