QComboBox eventFilter move item selection
-
Hello,
I have got a problem. I implemented my eventFilter to transform the keyPressed Qt::Key_Down in Qt::Key_Tab.
What I don't get is that, doing so, it does not move any more the selection of the item in the popup menu, but instead it directly change the document shown in the Widget associated to it.here is the code:
@bool eventFilter(QObject *t, QEvent *e)
{
QKeyEvent keyEvent = static_cast<QKeyEvent>(e);
int key = keyEvent->key();if(e->type() == QEvent::KeyPress) { switch(key) { case Qt::Key_Backtab: { QKeyEvent myEvent(QEvent::KeyPress, Qt::Key_Up, Qt::NoModifier); QComboBox::keyPressEvent(&myEvent); break; } case Qt::Key_Tab: { QKeyEvent myEvent(QEvent::KeyPress, Qt::Key_Down, Qt::NoModifier); QComboBox::keyPressEvent(&myEvent);
// int row = this->currentIndex();
// QString currentItem = this->itemText(row);
// this->setItemText(row, this->itemText(row+1));
// this->setItemText(row+1, currentItem);
break;
}
}
}@thanks.
qxoz: please use code tags