[Solved]get Keyboard's push and hold time duration seems impossible
-
- 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.onReleasedIt seems that impossible to do a keyboard push-and-hold triggered event.
Is it a bug of QML?
-
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 falseis it the reason?
-
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.
-
OK, Thank you very much.
Your response is just in time.