Details
-
Bug
-
Resolution: Done
-
P2: Important
-
5.2.1
-
Windows 7 64-bit MinGW48
Description
Here's some code to reproduce:
QColor color("#88112233");
QJsonValue jsonValue = QJsonValue::fromVariant(color);
qDebug() << color;
qDebug() << color.name();
qDebug() << QVariant(color);
qDebug() << QVariant(color).toString();
qDebug() << jsonValue;
// Debug output from above code
// QColor(ARGB 0.533333, 0.0666667, 0.133333, 0.2)
// "#112233"
// QVariant(QColor, QColor(ARGB 0.533333, 0.0666667, 0.133333, 0.2) )
// "#112233"
// QJsonValue(string, "#112233") <-- alpha value is missing
// It seems you have to do something manually like convert to rgba qint32 first...
QColor color;
QVariant v(color.rgba());
//Retrieve
QColor color = QColor::fromRgba(v.toUInt());
... but that isn't sufficient if you want to read QColor as a variant into a QJsonValue using QJsonValue::fromVariant()
Attachments
Issue Links
- relates to
-
QTBUG-43382 JSON.stringify does not handle Qt.point correctly
- Closed
For Gerrit Dashboard: QTBUG-37851 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
82114,1 | Fix conversion QVariant(QColor) to QString. | stable | qt/qtbase | Status: ABANDONED | -1 | 0 |
82370,1 | Fix conversion QVariant(QColor) to QString. | dev | qt/qtbase | Status: DEFERRED | +2 | 0 |
82957,1 | Do not assume QColor string format in qquickanimationcontroller. | dev | qt/qtdeclarative | Status: DEFERRED | 0 | 0 |
108048,3 | Fix conversion QVariant(QColor) to QString. | 5.6 | qt/qtbase | Status: MERGED | +2 | 0 |
163970,3 | Fix conversion QVariant(QColor) to QString | tqtc/vxworks-5.5 | qt/tqtc-qtbase | Status: MERGED | +2 | 0 |