[PyKDE] converting enum types
    Phil Thompson 
    phil at riverbankcomputing.co.uk
       
    Thu Jun  8 15:30:52 BST 2006
    
    
  
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.
> 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
    
    
More information about the PyQt
mailing list