[PyKDE] Problem with Flags in PyQt4

Phil Thompson phil at riverbankcomputing.co.uk
Sun Dec 11 12:22:25 GMT 2005


On Saturday 10 December 2005 6:13 pm, Baz Walter wrote:
> The PyQt4 implementation of Flags (such as QtCore.Qt.Alignment) has support
> for the and/or/xor binary arithmetic operations and augmented assignment.
>
> These works okay so long as both operands are Flags of the same type:
> >>> from PyQt4 import QtCore
> >>> a = QtCore.Qt.Alignment(QtCore.Qt.AlignmentFlag(0))
> >>> b = QtCore.Qt.Alignment(QtCore.Qt.AlignmentFlag(1))
> >>> int(a|b)
>
> 1
>
> ... but not if one operand is, say, an int or another type of Flag:
> >>> o = QtCore.Qt.Orientations(QtCore.Qt.Orientation(0))
> >>> int(a|o)
>
> Segmentation fault
>
> >>> int(a|3)
>
> Segmentation fault
>
> Is there any way to fix this so that it results in, say, a TypeError?

It will be fixed in tonight's SIP snapshot.

> Also, would it be possible to have a default argument of zero/None for
> these
>
> Flags so they can be created like this:
> >>> f = QtCore.Qt.Orientations()
> >>> int(f)
>
> 0

It will be in tonight's PyQt snapshot.

Thanks,
Phil




More information about the PyQt mailing list