PDA

View Full Version : Keypress never fired on lineedit qcombobox



stef13013
6th August 2012, 17:46
Hi,

I added an eventfilter() to the lineedit() of a qcombobox
Then event() is called but not the keypress type.



// create combo
//
cb = new QComboBox();
...
cb->setEditable(true);
cb->lineEdit()->installEventFilter(this);

...

bool MainWindow::eventFilter(QObject *obj, QEvent *event)
{
if (obj==cb->lineEdit())
{
// lots of events are fired but never keypress !!??
if (event->type() == QEvent::KeyPress)
{
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);

if (keyEvent->key() == Qt::Key_Period)
{
....
return true;
}
}

return false;
}
else
return QMainWindow::eventFilter(obj, event);
}


I've got the feeling I've forgotten something but what ??

Thanks...

Added after 28 minutes:

I guess I understand,

EventFilter() must be on combo and not on lineedit !!!
Wow not so easy...

A big Thanks to the open source !!!