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 > trick
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. > > Really: > model = MyCompletionModel() > self.setModel(model) > > 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) Andreas -- Lady Luck brings added income today. Lady friend takes it away tonight. _______________________________________________ PyQt mailing list [email protected] http://www.riverbankcomputing.com/mailman/listinfo/pyqt
