Description
Inside QtCore.QAbstractItemModel.data() we might have code like this
if role == QtCore.Qt.TextAlignmentRole: if case_a: return QtCore.Qt.AlignRight elif case_b: return QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter else: return QtCore.Qt.AlignVCenter
Case a works (kind of) in that we get right alignment but vertical alignment changes from the AlignVCenter default to AlignTop.
Case b does not work: the alignment value is ignored.
Case c works.
What seems to be going on is that the caller of data() expects an int return not an Alignment object. If we replace by
if role == QtCore.Qt.TextAlignmentRole: if case_a: return int(QtCore.Qt.AlignRight) elif case_b: return int(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter) else: return int(QtCore.Qt.AlignVCenter)
it works.
Simple example enclosed.
Attachments
Issue Links
- duplicates
-
PYSIDE-1930 REG ->6.2.4: Cannot return Qt.CheckState enum values from QAbstractItemModel::flags()
- Closed
- is duplicated by
-
PYSIDE-1537 Qt.AlignRight | Qt.AlignVCenter is ignored
- Closed
- relates to
-
PYSIDE-628 QFont.StyleStrategy values convert to int when bitwise or'd
- Closed
-
PYSIDE-1974 Regression: Usage of PySide6 enums via QVariant broken
- Closed
For Gerrit Dashboard: PYSIDE-168 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
221627,8 | WIP: Complete implementation of the QFlag type | 5.14 | pyside/pyside-setup | Status: ABANDONED | -2 | 0 |
288381,5 | Fix Python 3.8 warnings about deprecated int conversions of enums/flags | 5.14 | pyside/pyside-setup | Status: MERGED | +2 | 0 |