73 bool convert(
const void *from,
int fromTypeId,
void *to,
int toTypeId)
const override
75 Q_ASSERT(fromTypeId != toTypeId);
77 bool onlyCheck = (from ==
nullptr && to ==
nullptr);
79 Q_ASSERT(onlyCheck || (
bool(from) &&
bool(to)));
81#if QT_CONFIG(shortcut)
84 switch (makePair(toTypeId, fromTypeId)) {
85 QMETATYPE_CONVERTER(QByteArray, QColor,
86 result = source.name(source.alpha() != 255 ?
87 QColor::HexArgb : QColor::HexRgb).toLatin1();
90 QMETATYPE_CONVERTER(QColor, QByteArray,
91 result = QColor::fromString(QLatin1StringView(source));
92 return result.isValid();
94 QMETATYPE_CONVERTER(QString, QColor,
95 result = source.name(source.alpha() != 255 ?
96 QColor::HexArgb : QColor::HexRgb);
99 QMETATYPE_CONVERTER(QColor, QString,
100 result = QColor::fromString(source);
101 return result.isValid();
103#if QT_CONFIG(shortcut)
104 QMETATYPE_CONVERTER(QString, QKeySequence,
105 result = source.toString(QKeySequence::NativeText);
108 QMETATYPE_CONVERTER(QKeySequence, QString, result = source;
return true;);
109 QMETATYPE_CONVERTER(Int, QKeySequence,
110 result = source.isEmpty() ? 0 : source[0].toCombined();
113 QMETATYPE_CONVERTER(QKeySequence, Int, result = source;
return true;);
115 QMETATYPE_CONVERTER(QString, QFont, result = source.toString();
return true;);
116 QMETATYPE_CONVERTER(QFont, QString,
return result.fromString(source););
117 QMETATYPE_CONVERTER(QPixmap, QImage, result = QPixmap::fromImage(source);
return true;);
118 QMETATYPE_CONVERTER(QImage, QPixmap, result = source.toImage();
return true;);
119 QMETATYPE_CONVERTER(QPixmap, QBitmap, result = source;
return true;);
120 QMETATYPE_CONVERTER(QBitmap, QPixmap, result = QBitmap::fromPixmap(source);
return true;);
121 QMETATYPE_CONVERTER(QImage, QBitmap, result = source.toImage();
return true;);
122 QMETATYPE_CONVERTER(QBitmap, QImage, result = QBitmap::fromImage(source);
return true;);
123 QMETATYPE_CONVERTER(QPixmap, QBrush, result = source.texture();
return true;);
124 QMETATYPE_CONVERTER(QBrush, QPixmap, result = source;
return true;);
125 QMETATYPE_CONVERTER(QColor, QBrush,
126 if (source.style() == Qt::SolidPattern) {
127 result = source.color();
132 QMETATYPE_CONVERTER(QBrush, QColor, result = source;
return true;);