PDA

View Full Version : keyPressEvent not being caught



vieraci
29th October 2007, 08:39
I've promoted a comboBox part and then in the source file I put the following code:


void promotedPart::keyPressEvent(QKeyEvent* e)
{
QComboBox::keyPressEvent(e);
if (e->key() == Qt::Key_Enter || e->key() == Qt::Key_Return)
{
handleReturnPressed();
}
}

Nothing happens. :confused:

BTW: Dunno how to Thank you all so much for the better-than-excellent support I've received from you guys in past posts, Linux and Qt is bloody fantastic !! You guys make it so. Without you guys, It would just be another os and development environment.
Thanks! :)

wysota
29th October 2007, 09:01
Nothing happens. :confused:
Could you verify that the method actually gets called? You can do that by putting a qDebug() statement there. I suspect that Return/Enter might be handled on a different level - even in an event filter of the combobox. If you verify that the method is not called, try reimplementing event() instead or apply an event filter on your combobox subclass and handle it there. At least the last solution has to work (and you can do that even without subclassing).


BTW: Dunno how to Thank you all so much for the better-than-excellent support I've received from you guys in past posts, Linux and Qt is bloody fantastic !! You guys make it so. Without you guys, It would just be another os and development environment.
Thanks! :)
Thx.

vieraci
29th October 2007, 12:53
Strange thing:
Not sure what I did now.
I inserted some qDebug lines and found keyPressEvent() was now being called, and also promotedPart::returnPressed() began to function too !!
But when I dropped keyPressEvent(), promotedPart::returnPressed() stopped working :confused: