0

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();
    ...
}
shan
  • 1,164
  • 4
  • 14
  • 30
  • What is a Filter widget? Is it a standard type of widget (on other platforms, but not available in Qt), or did you make up the name yourself? If it's something standard, you can post links to examples of it. – sashoalm Dec 05 '12 at 13:31
  • No. it is not a standard widget. I put that name because it will search and filter combobox items as i type. – shan Dec 06 '12 at 04:44

1 Answers1

0

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

shan
  • 1,164
  • 4
  • 14
  • 30