Details
-
Bug
-
Resolution: Done
-
P1: Critical
-
6.5.0 Beta1, 6.x
-
None
-
98e21f0979 (qt/qtbase/dev) 98e21f0979 (qt/tqtc-qtbase/dev) 729a326d85 (qt/qtbase/6.3) 729a326d85 (qt/tqtc-qtbase/6.3) 2932130a8e (qt/qtbase/6.4) 2932130a8e (qt/tqtc-qtbase/6.4) 2932130a8e (qt/tqtc-qtbase/6.4.0) b0ea59146e (qt/tqtc-qtbase/6.2)
Description
For example (Qt::textFormat is an enum while Qt::Alignment is a QFlags):
const QVariant v1("RichText"); const QVariant v2("AlignBottom"); QLabel l; qDebug() << l.setProperty("textFormat", v1); // true in Qt 5 and 6 qDebug() << l.setProperty("alignment", v2); // true in 5, FALSE in 6
What it looks like to me is that setProperty() ends up in QMetaProperty::write(), and in Qt 5, it enters the block that calls key[s]ToValue(), which successfully decodes the string to enum values. But in Qt 6, that block is never entered at all, since it is behind this (changed) test:
if (isEnumType() && !t.metaObject() && v.metaType().id() == QMetaType::QString)
and the middle term fails - both the metatypes do in fact have a metaObject. But I don't know if that test is as it should be or not.
Anyway, we next run into another Qt 6 issue/bug, in QVariant, which may or may not be related. Since, we did not enter the block above, the code instead tries to call QVariant::convert(). That succeeds for TextFormat but fails for Alignment - even though the QVariant claims to be able to convert a string in Qt 6:
qDebug() << v1.canConvert<Qt::TextFormat>(); // true Qt 5 and 6 qDebug() << v1.value<Qt::TextFormat>(); // Qt::RichText in 5 and 6 qDebug() << v2.canConvert<Qt::Alignment>(); // false 5, TRUE in 6 ? qDebug() << v2.value<Qt::Alignment>(); // empty QFlags in 5 and 6
Attachments
Issue Links
- is required for
-
QTBUG-96185 Cannot use "qproperty-" to set enum properties in qss
- Closed