hubbobubbo
1st June 2010, 12:49
I have inherited the keyPress and keyRelease like below and the functions are called. The problem is that they are called a ton of times. If I press one key and keep it pressed I keep getting loads of keyPressed and keyRelease events even though the key is still down. If I just click the button normally it is ok, one keyPressed and one keyReleased but when I keep the button down there are multiple events for both pressed and released.
I test this on Win32 and I have tried it both in QMainWindow and a QDialog with the same problem.
void myDialog::keyPressEvent( QKeyEvent * event )
{
qDebug("Detected key %d down", event->key());
lbl->setText(tr("Down"));
}
void myDialog::keyReleaseEvent( QKeyEvent * event )
{
qDebug("Detected key %d up", event->key());
lbl->setText(tr("UP"));
}
I test this on Win32 and I have tried it both in QMainWindow and a QDialog with the same problem.
void myDialog::keyPressEvent( QKeyEvent * event )
{
qDebug("Detected key %d down", event->key());
lbl->setText(tr("Down"));
}
void myDialog::keyReleaseEvent( QKeyEvent * event )
{
qDebug("Detected key %d up", event->key());
lbl->setText(tr("UP"));
}