Question

I want to implement Filter widget using QComboBox. The way it should work is, when I type letter 'a' it should show the items that are starting with 'a', and then if I type 'b' it should show the items that have the prefix 'ab' etc. I tried by overriding keyPressEvent of QComboBox class, but it didn't work. The main problem I got is, how can I make the QComboBox editable while the drop down list is appearing ? I'm opening dropdown list inside the key press event like this,

void SearchCombo::keyPressEvent(QKeyEvent *e)
{
    ...
    listBox()->popup();
    ...
}
Was it helpful?

Solution

I found a solution. What i did is, passing the QListBox's (QComboBox has a listbox) keyPressEvent's QKeyEvent to the QComboBox's LineEdit. Inside the LineEdit overrode keyPressEvent called using that QKeyEvent

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top