[PyKDE] converting enum types

Patrick Stinson patrickkidd.lists at gmail.com
Thu Jun 8 20:29:32 BST 2006


On 6/8/06, Phil Thompson <phil at riverbankcomputing.co.uk> wrote:
> On Thursday 08 June 2006 2:55 pm, Patrick Stinson wrote:
> > It seems like everywhere that there is an enum value returned from a
> > function, like QInputEvent.modifiers(), you get a class defined by
> > pyqt. What is the idea behind returning an object of this type instead
> > of an int,
>
> Because enums aren't ints, they are distinct types.

funny what you forget when you forsake the rest of the world for a
life in python...

>
> > and where do you need to construct one? I found the bitwise
> > operators in the pyqt4 class ref, so I assume they work just like
> > ints....
>
> SIP generated enums are subclasses of the Python int type so they can used
> anywhere where an int is expected. The Qt4 flag types (and the automatic
> conversions that PyQt supports) allow you to do bit operations without losing
> the type information.
>
> You rarely need to apply any type convertors in PyQt4. The exception is if you
> are reading enums from a file.
>
> Phil
>
> _______________________________________________
> PyKDE mailing list    PyKDE at mats.imk.fraunhofer.de
> http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
>


-- 
Patrick Kidd Stinson
http://www.patrickkidd.com/
http://pkaudio.sourceforge.net/
http://pksampler.sourceforge.net/




More information about the PyQt mailing list