QKeyEvent and last release event
-
I reimplemented the following functions:
@
void keyPressEvent(QKeyEvent *);
void keyReleaseEvent(QKeyEvent *);
@in order to catch when the user press or release some keys.
I'm interested only to the first press event and to the last release one.The former is straightforward: it's enough to check the isAutoRepeat value. I don't know how to catch the last release event instead.
My only idea is to use a QTimer to detect a timeout in the autorepeat... but it's not very handy because each user may have different repetition timing.I just want to intercept when the user physically raises the key. How to?
-
Hi, AFSIK, isAutoRepeat works for keyRelease too.
-
Yes, but it's not useful. I've just tried again: press and hold a key, then release it. Here the output;
@
// press and hold the key
pressEvent, isAutoRepeat = false
releaseEvent, isAutoRepeat = false
pressEvent, isAutoRepeat = true
releaseEvent, isAutoRepeat = true
pressEvent, isAutoRepeat = true
releaseEvent, isAutoRepeat = true
pressEvent, isAutoRepeat = true
releaseEvent, isAutoRepeat = true
.
.
.
@Yes, it tells me the release event is generated by an "auto repetition" of the key. But I have no information about the last event. I mean the last event after the user has really released the key.
-
In Qt5.1/Windows XP, the result is:
@
// press and hold the key
pressEvent, isAutoRepeat = false
releaseEvent, isAutoRepeat = true
pressEvent, isAutoRepeat = true
releaseEvent, isAutoRepeat = true
pressEvent, isAutoRepeat = true
releaseEvent, isAutoRepeat = true
pressEvent, isAutoRepeat = true
releaseEvent, isAutoRepeat = false
@