Details
-
Bug
-
Resolution: Done
-
P2: Important
-
5.9.7, 5.12.2
-
None
-
6880b7c39b (qt/qtbase/dev) a591865844 (qt/qtbase/6.3) 35a09fc7e9 (qt/qtbase/6.2) 35a09fc7e9 (qt/tqtc-qtbase/6.2) a591865844 (qt/tqtc-qtbase/6.3) 6880b7c39b (qt/tqtc-qtbase/dev)
Description
The documentation for the built-in roles say that certain dataypes are expected to be returned from the model:
https://doc.qt.io/qt-5/qt.html#ItemDataRole-enum
Qt::TextAlignmentRole The alignment of the text for items rendered with the default delegate. (Qt::Alignment)
However, actually returning some of those datatypes does not work. For instance for Qt::TextAlignmentRole one actually has to return an int. The reason boils down to the default delegate using an int:
https://code.woboq.org/qt5/qtbase/src/widgets/itemviews/qstyleditemdelegate.cpp.html#287
value = index.data(Qt::TextAlignmentRole);
if (value.isValid() && !value.isNull())
option->displayAlignment = Qt::Alignment(value.toInt());
This is very related to having an automatic QFlags to int conversion performed by QVariant (see QTBUG-74639 and friends). If anything, the documentation has to be amended, and I'd really like to have the feature in QVariant itself so one can return the real datatype and not int.
Attachments
Issue Links
- relates to
-
PYSIDE-2339 Enums returned from QAIM::data() get casted to ints for StyledItemDelegate.displayText()
- Closed