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