PDA

View Full Version : Avoiding Keystroke repetition.



gilouu
18th February 2015, 18:13
Hello,

I'm working on Windows and I have the following problem :

By pressing and maintainting a single key (for example the 'R' key), I want to catch the KeyPressEvent : No problem.
Another fonction will be activated by KeyReleaseEvent...

But, as the user press the key for a while, the system (Windows) do a key repetition aswell as it fires the keyReleasedEvent !

Have you a solution ?

Gilles

d_stranz
18th February 2015, 19:03
QKeyEvent::isAutoRepeat()

gilouu
18th February 2015, 19:46
Hello d_stranz,

That's it !
Thank you.

Here is my function using it :


void GLWidget::keyReleaseEvent(QKeyEvent *event){
switch (event->key()){
case Qt::Key_R :
if(event->isAutoRepeat()) break;// if the event comes from autoRepeat from system, we stop.
qApp->takeOfMode(KEY_R);
qApp->takeOfMode(IN_COPY);
this->listOfElement->takeOffModeAtAll(AUTO_INCLUDED);
break;

case Qt::Key_Shift :
qApp->takeOfMode(KEY_SHIFT);
break;
}
}