[PyKDE] Problem with Flags in PyQt4
Baz Walter
bazwal at ftml.net
Sat Dec 10 18:13:29 GMT 2005
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?
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
Regards
--
Baz Walter
More information about the PyQt
mailing list