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