Details
-
Bug
-
Resolution: Done
-
P3: Somewhat important
-
None
-
6.3.1
-
None
-
All
-
-
f8e945097c (pyside/pyside-setup/dev) eb845eb705 (pyside/pyside-setup/6.3) eb845eb705 (pyside/tqtc-pyside-setup/6.3) f8e945097c (pyside/tqtc-pyside-setup/dev) eb845eb705 (pyside/pyside-setup/wip/6.3_pypy) eb845eb705 (pyside/tqtc-pyside-setup/wip/6.3_pypy)
Description
Returning a PySide 6 enum for role Qt.ItemDataRole.TextAlignmentRole from the data() method of a model is broken in Qt 6.3.1. Sample code below:
from PySide6.QtCore import Qt, QAbstractTableModel from PySide6.QtWidgets import QTableView, QApplication class M(QAbstractTableModel): def rowCount(self, *a): return 1 def columnCount(self, *a): return 1 def data(self, index, role): if role == Qt.ItemDataRole.DisplayRole: return 'testing' if role == Qt.ItemDataRole.TextAlignmentRole: ans = Qt.AlignmentFlag.AlignVCenter | Qt.AlignmentFlag.AlignHCenter return ans app = QApplication([]) v = QTableView() v.setModel(M()) v.resize(v.sizeHint()) v.show() app.exec()
The string testing is displayed in the top left corner instead of centered. Changing return ans to return int(ans) gives the expected behavior. Therefore, conversion of the PySide6 enum to int is failing. This used to work fine with Qt 6.2.3. It also fails with PyQt6.
Attachments
Issue Links
- relates to
-
PYSIDE-168 QtCore.Alignment objects are not correctly interpreted when returned from item.data()
- Closed
-
PYSIDE-1930 REG ->6.2.4: Cannot return Qt.CheckState enum values from QAbstractItemModel::flags()
- Closed
- resulted from
-
PYSIDE-1798 Cannot store enum Qt.PenStyle object as user data of QComboBox item (QVariant)
- Closed