[PyKDE] className()

Phil Thompson phil at river-bank.demon.co.uk
Fri Jul 6 16:05:25 BST 2001

Boudewijn Rempt wrote:
> I had to find out the name of a class from the instance of a class,
> and I found the className() function of QObject. However, when I
> tried to use it, I came across the following:
> >>> from qt import *
> >>> a=QPlatinumStyle()
> >>> print a
> <qt.QPlatinumStyle instance at 0x8308f94>
> >>> print a.className()
> QObject
> >>> print isinstance(a, QPlatinumStyle)
> 1
> And I was much surprised. Obviously, sip knows what this is - but
> the className() function doesn't. Is this merely a bug in sip, or
> do I have to parse the repr output?
> (If you want to know what I needed this for - wait till Friday,
> when I hope the new chapter on configuration files goes up...)

It's a bug in SIP - the same problem as there was with QObject.tr(), ie.
SIP wasn't emulating moc in automatically creating these methods in
sub-classes of QObject. Therefore it was falling back to the QObject
implementation of className().

Will be fixed in the next pre-release.


More information about the PyQt mailing list