[PyKDE] tableview and model

Phil Thompson phil at riverbankcomputing.co.uk
Sat Feb 25 14:05:19 GMT 2006


On Saturday 25 February 2006 12:49 pm, Andreas Pakulat wrote:
> On 25.02.06 02:10:06, Andreas Pakulat wrote:
> > On 24.02.06 18:45:18, Phil Thompson wrote:
> > > On Friday 24 February 2006 3:48 pm, Olivier Fournier wrote:
> > > > I'll be happy you can help me!
> > >
> > > Because setModel() doesn't take ownership of the model. In the first
> > > example model stays alive while it is being used. In the second it is
> > > garbage collected while it is still in use.
> >
> > Huh? I thought we already corrected this?
>
> Just to make sure I get this right: Using the Qt-delivered models I have
> to keep a reference to them, but when I subclass those models I don't?
> Because here the following works perfectly:
>
> self.tableview.setModel(MyModel(list_))
>
> There MyModel is derived from QAbstractItemModel and list_ is just a
> list of data items.

It may appear to work, but it's wrong (unless you are doing something in 
MyModel.__init__ to keep the reference alive).

Phil




More information about the PyQt mailing list