[Qt-interest] QCompleter with QAbstractTableModel or QSortFilterProxyModel ?
Andre Somers
andre at familiesomers.nl
Sun Sep 12 13:48:08 CEST 2010
Op 9-9-2010 17:39, Till Priemer schreef:
> Hello,
>
> I use QCompleter with QAbstractListModel in QLineEdit. Works fine. Now I
> want to reduce the Number of Items dynamically in the model seen by the
> QCompleter based on additional attributes (e.g. I have a list of names as
> QStringListModel but now I want to use the male ones within the completer
> only). My Idea was to use a QTableModel instead of QStringModel and store
> the name in the first column and the other attributes (gender, age, ...) in
> the following columns. Then I use a QSortFilterProxyModel for filtering the
> attribute I want. The QCompleter gets the proxyModel as model().
> But the documentation of QCompleter says the only models allowed are list-
> and tree-models !?
>
> why isn't it possible to use QSortFilterProxyModel?
>
>
I think it *is* possible, actually.
Completion can only be done using a list or a tree structure in the data
model, but nobody said that that structure can't come from/through a
proxy. Just be sure that the data you want in your completer ends up in
the first column. You can use your proxy to filter on any other column
you want.
André
More information about the Qt-interest-old
mailing list