Details
-
Bug
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
6.10
-
None
Description
QInternalMimeData::retrieveData() expects the application/x-color mime type to provide 8 bytes, apparently raw RGBA:
QVariant QInternalMimeData::retrieveData(const QString &mimeType, QMetaType type) const { ... } else if (mimeType == "application/x-color"_L1 && data.metaType().id() == QMetaType::QByteArray) { QColor c; QByteArray ba = data.toByteArray(); if (ba.size() == 8) { ushort * colBuf = (ushort *)ba.data(); c.setRgbF(qreal(colBuf[0]) / qreal(0xFFFF), qreal(colBuf[1]) / qreal(0xFFFF), qreal(colBuf[2]) / qreal(0xFFFF), qreal(colBuf[3]) / qreal(0xFFFF)); data = c; } else { qWarning("Qt: Invalid color format"); }
But QMimeDataPrivate::retrieveTypedData() provides a 7-byte hex color representation (e.g. "#440044" or so, the ASCII bytes):
} else if (typeId == QMetaType::QByteArray) { // try to convert to bytearray switch (data.metaType().id()) { case QMetaType::QByteArray: case QMetaType::QColor: qDebug() << "color -> BA" << data << data.toByteArray(); return data.toByteArray();
The result is that the fix https://codereview.qt-project.org/c/qt/qtdeclarative/+/626673 for QTBUG-134226 doesn't actually allow me to drag a QColor from a QML application to qtbase/examples/widgets/draganddrop/dropsite.
The question is, which one is right. I can drag a color from the QML application to GIMP's toolbox, FWIW.
But we should support alpha somehow. I guess that's the reason for expecting a raw RGBA color. But there is also a valid hex representation for a color with alpha; so I guess QInternalMimeData::retrieveData() needs to be more flexible.
It would be best to find a spec for this first, where the expectations for application/x-color are documented. (Should we support named colors too, for example?)
Attachments
Issue Links
- is required for
-
QTBUG-121786 Verify that drag and drop between widgets and Qt Quick works
-
- Open
-
- relates to
-
QTBUG-4175 Drag and Drop of Color on Mac OS X Not Working
-
- Closed
-
- resulted from
-
QTBUG-134226 Warning about application/x-color in QtQuick Drag
-
- Closed
-