[PyQt] auto-completing combo box with table view
apaku at gmx.de
Wed Nov 28 12:02:21 GMT 2007
On 28.11.07 22:16:09, Horst Herb wrote:
> On Wednesday 28 November 2007, Andreas Pakulat wrote:
> > That model provides data, no matter wether the index is valid or not or
> > the role matches Qt.DisplayRole. That means you break the contract
> > between model and view.
> It is just a dummy to deliver some data to test the widget - should do that
Not necessarily, especially the role-thing might confuse the view.
> > > class MyCompleter(QCompleter):
> > > def __init__(self, parent=None):
> > > super(MyCompleter, self).__init__(parent)
> > > model = MyCompletionModel()
> > Thats another bad idea, you don't keep a reference to the model so it
> > will disappear as soon as __init__ is done.
> model = MyCompletionModel()
> I would have thought that if I pass the model to the completer via setModel,
> it keep the reference alive
AFAIK thats not possible, due to the interaction between C++ and Python
here, i.e. what is kept is the C++ part of your model, but the python
part goes into nirvana. (I hope Phil doesn't kill me for that
explanation). Check the PyQt examples, they do keep a reference to the
model too (simpledommodel.py for example)
Lady Luck brings added income today. Lady friend takes it away tonight.
More information about the PyQt