Can I make QCompleter complete inline and show popup
Qt 4.5 (PyQt 4.6.1)
I am looking for a widget similar to QComboBox
that that automatically filters its entries to those that start with typing in a textbox. The combo box contains about 300 items.
I've tried two approaches:
QLineEdit
from QCompleter
Benefits
- Filtering items works.
disadvantages
- No popup is displayed if the text box is empty.
- Doesn't perform inline completion.
- Allows you to insert items that are not in the list.
Editable QComboBox
with no insert setting
Benefits
- Nice popup
- Terminates the inline in the text field.
disadvantages
- No filtration
- Entry is only possible in a text box or pop-up window. When clicking on the popup, the popup does not select the best matching item.
What I need
- Pop-up window for selecting items.
- Slow dumpers should be able to start rolling over the item name and the popup switches to best match.
- Preferably I should filter the items so that only partial match items are shown.
source to share
As for the first try with QLineEdit, you can set completionMode
to do it inline.
For your second try, you can add a QCompleter object to the QCombBox to filter your items as you wish. The QCompleter member QComboBox offers an easy way to use QCompleter.
In any case, if you are not satisfied with this method, you can manipulate the object yourself QCompleter
. This allows you to choose how the list of items is displayed (using any views) and determine the order of the items in the list. See QCompleter Basic Details .
source to share