[PyKDE] PyQt Metaclass programming

Phil Thompson phil at riverbankcomputing.co.uk
Thu Oct 28 08:59:02 BST 2004


> Howdy!
>
> I'm presently using QCustomEvent quite often, and decided to whip up a
> solution using metaclasses.  The idea being that the custom event number
> could be automatically incremented for each custom event -- so it would
> be unnecessary to number them manually.
>
> However, trying to create a subclass of class 'type' and assign it to a
> class with __metaclass__ generates an error.  Turns out, sip.wrappertype
> is the metaclass of QCustomEvent.  However, sip.wrappertype does not
> appear to be visible in the sip module.
>
> Does anyone know an easy way to attach a metaclass to a subclass of a
> PyQt class?  It is simple enough to make a class factory, but it seems
> more elegant to delegate that task to a metaclass.  Thanks!

Would it help if sip.wrappertype was placed in the sip module dictionary
so that you could sub-class it?

Phil




More information about the PyQt mailing list