[PyQt] Just for fun: QCompleter accessing a QListWidget's internal model through a "proxy" ?

fpp fpp.gsp at gmail.com
Tue Aug 17 20:37:57 BST 2010


On Tue, Aug 17, 2010 at 9:25 PM, Matt Newell <newellm at blur.com> wrote:

> On Tuesday 17 August 2010 11:23:55 fpp wrote:
>> So I thought, perhaps naively, that it might be possible to build a
>> kind of "proxy" model, that would feed a completer with data pulled
>> from a list widget's hidden, internal model.
>>
> I could be overlooking something but I don't see why you can't use the list
> widget's model directly.  The details of the implementation may be private, but
> the QAbstractItemModel interface is still public and usable.
> Should be as simple as
> completer = QCompleter( listWidget.model(), parent )

Indeed it is !... self.slaps_forehead()

Wow, that was quick... so it was actually option #2 of my self-prediction:
> or else it is so trivial that no one has ever thought of documenting it, and I'm just missing something really obvious.

...which is good news. Just the usual result of my inability to parse
the Qt docs, wrap my head around object models, and generally add two
plus two.

Thanks Matt !
fp


More information about the PyQt mailing list