PDA

View Full Version : Howto handle key-release with autorepeat key



gould75
19th August 2006, 21:57
Hi all,
if I press an autorepeat key (like space or a character key) without release the key,
the keyPressEvent and keyReleaseEvent are emitted continuosly until the key is released. So, how can I handle the "true" release of the key??
Any suggestion?
Thanks,
Marco


See this example:

void MyWidget::keyPressEvent(QKeyEvent * event)
{
qDebug() << "press";
...
}

void MyWidget::keyReleaseEvent(QKeyEvent * event)
{
qDebug() << "release";
...
}


<<< I press space key >>>
output will be:
press
release
press
release
press
release
...
<<< I release the space key >>>
release

jacek
19th August 2006, 22:15
Did you try checking QKeyEvent::isAutoRepeat()?

gould75
20th August 2006, 07:52
Thanks this solve my problem!
I thought that isAutoRepeat() method was for another purpose.
Bye,
Marco


Did you try checking QKeyEvent::isAutoRepeat()?