Generous Genius Programmer Shares Secrets of PyQt Multiple Autocomplete

It so happens I was looking for a way to do multiple autocompletes in a QComboBox.

In other words, I had an editable combo box containing the list:
– cupcake
– muffin
– pie

I wanted the user to be able to type “p” and have it autocomplete to “pie.”
This is no problem. Qt makes this automatic and wonderful, and it is a reason I want to give Qt a hug sometimes.

But then I want the user to keep typing “pie c” and have the combo box autocomplete “pie cupcake.”

This is a bit trickier.

I had seen some code for doing one’s own autocompletion combo box from scratch, and let us just say I did not want to write any.

So I sniffed around and found John Schember’s post about QCompleter and autocompleting multiple entries, and I was saved!


Fortunately, a QComboBox contains a QLineEdit object, so I was able to adapt this code while being very very lazy.

Woot. Thank you, John Schember.


Draws. Sweats. Eats too much sugar-free candy.

You may also like...

1 Response

  1. Your Anomalous Fan says:

    Once again, you’re speaking geek and I don’t have the slightest idea what you’re saying, so I’ll just leave this here.

    Dreamworks storyboard artist + ninjas = aaarsome.

%d bloggers like this: