[PyKDE] subclassing in pyqt

Boudewijn Rempt bsarempt at rempt.xs4all.nl
Sat Dec 23 22:52:10 GMT 2000

On Sat, 23 Dec 2000, Phil Thompson wrote:

> Here is a thought...
> As I've explained before, the C++ QListViewItem instance doesn't get
> deleted when the Python object is deleted because its ownership is
> transfered to the Qt code. What if I increased the reference count of
> the Python instance when ownership is transfered to Qt? Qt then has
> responsibility for deleting the reference count - and therefore the
> Python object would stick around even though you weren't holding an
> explicit reference in your Python code.
> This goes against my previously stated philosophy of not messing with
> reference counts under the covers - but I can't think of any new
> problems it would create.
> Anybody any thoughts on whether or not this would break anything?

I don't think it would break anything - if QListViewItems would get
deleted when the Python reference got deleted, yes, but you've got
to use QListView.takeItem() anyway.

I haven't got any strong feelings: in most application, you'd want
to keep a mapping between a listviewitem and the object that it 
represents anyway, and then you've got your reference for free.

Boudewijn Rempt

More information about the PyQt mailing list