PDA

View Full Version : keyPressEvent - "ctrl + tab" handle two time



somename
30th May 2010, 19:28
bool Widget::eventFilter(QObject *target, QEvent *event)
{
QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
if (keyEvent->modifiers() == Qt::ControlModifier) {
if (keyEvent->key() == Qt::Key_Tab) {
qDebug() << "Handling..";
return true;
}
return false;
}
}


then I see that this handler called two time:

ApplicationOutput:
Handling..
Handling..

Lykurg
30th May 2010, 19:34
did you hold the button, then see autoRepeatDelay, autoRepeatInterval.

somename
30th May 2010, 19:59
No, I have no button

tbscope
30th May 2010, 20:10
No, I have no button

The ctrl and tab button (key)

SixDegrees
30th May 2010, 20:17
KeyEvent records any sort of key event - both key press and key release. You're probably seeing the initial press followed by the subsequent release being processed here.

Check the Type of the event to see if it is KeyPress or KeyRelease, and only handle one of them.

somename
30th May 2010, 20:23
Thanks! I have forgotten this!

somename
30th May 2010, 20:28
and..
How to use auto repeat delay?

Lykurg
30th May 2010, 21:29
I never have dealt with such kind, but I would start with: QShortcut::autoRepeat.