[PyKDE] tableview and model

Andreas Pakulat apaku at gmx.de
Sat Feb 25 15:57:53 GMT 2006


On 25.02.06 14:05:19, Phil Thompson wrote:
> On Saturday 25 February 2006 12:49 pm, Andreas Pakulat wrote:
> > 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).

Aaah, now I understand. I do 

QAbstractItemModel.__init__(self, parent)

in MyModel.__init__ and when creating the model I pass "self" as parent
to the MyModel constructor. (self beeing a QWidget-derived class)

Ok, case closed, for me.

Andreas

-- 
Don't relax!  It's only your tension that's holding you together.




More information about the PyQt mailing list