[PyKDE] QListView(Item) subclass insertItem strange behaviou

marvelan L marvelan at hotmail.com
Sun Jan 5 10:00:00 GMT 2003


In my real code (not this test) I try to call methods of my own
class and they fail as the object is of wrong type. So I'm sure
that the methods are called with the wrong type of object. So
the python __class__ seems to be really runtime inspection and
returns the real thing...

So, I'm pretty sure that the QListViewItem.insertItem is called
with a QListViewItem and not my own sub class...

I tried to look at the PyQt code to see if I could make something
out of it. I couldn't.

>
> > The problem is that I need to access my own added methods in
> > MyList when insertItem is called. But it seems that it is called
> > with a object of the base class and not my specialisation class
> > MyList.
>
>Since it's printing, it would seem that the overloaded methods are
>being called correctly. You can test which object (base or sub
>class) is actually instantiated by calling a subclass-only method
>using the object in question. If the object is of the base class
>type, the call to a subclass method will fail.
>
>I'm not sure how __class__ works with PyQt classes, but if it uses
>QObject.className in some way, it's unlikely to report a
>Python-created subclass correctly. From your post, it doesn't appear
>that what __class__ returns is important, but just that the correct
>object type is instantiated.
>

_________________________________________________________________
MSN 8: advanced junk mail protection and 2 months FREE*. 
http://join.msn.com/?page=features/junkmail




More information about the PyQt mailing list