Hi,
I added an eventfilter() to the lineedit() of a qcombobox
Then event() is called but not the keypress type.
// create combo
//
...
cb->setEditable(true);
cb->lineEdit()->installEventFilter(this);
...
{
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
}
// 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);
}
To copy to clipboard, switch view to plain text mode
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 !!!
Bookmarks