41 case QMetaType::Type::UnknownType:
43 case QMetaType::Type::Bool:
44 return QObject::tr(
"Boolean" );
45 case QMetaType::Type::Int:
46 return QObject::tr(
"Integer (32 bit)" );
47 case QMetaType::Type::UInt:
48 return QObject::tr(
"Integer (unsigned 32 bit)" );
49 case QMetaType::Type::LongLong:
50 return QObject::tr(
"Integer (64 bit)" );
51 case QMetaType::Type::ULongLong:
52 return QObject::tr(
"Integer (unsigned 64 bit)" );
53 case QMetaType::Type::Double:
54 return QObject::tr(
"Decimal (double)" );
55 case QMetaType::Type::QChar:
56 return QObject::tr(
"Character" );
57 case QMetaType::Type::QVariantMap:
58 return QObject::tr(
"Map" );
59 case QMetaType::Type::QVariantList:
63 case QMetaType::Type::Int:
64 return QObject::tr(
"Integer List" );
65 case QMetaType::Type::LongLong:
66 return QObject::tr(
"Integer (64 bit) List" );
67 case QMetaType::Type::Double:
68 return QObject::tr(
"Decimal (double) List" );
70 return QObject::tr(
"List" );
73 case QMetaType::Type::QString:
74 return QObject::tr(
"Text (string)" );
75 case QMetaType::Type::QStringList:
76 return QObject::tr(
"String List" );
77 case QMetaType::Type::QByteArray:
78 return QObject::tr(
"Binary Object (BLOB)" );
79 case QMetaType::Type::QBitArray:
80 return QObject::tr(
"Bit Array" );
81 case QMetaType::Type::QDate:
82 return QObject::tr(
"Date" );
83 case QMetaType::Type::QTime:
84 return QObject::tr(
"Time" );
85 case QMetaType::Type::QDateTime:
86 return QObject::tr(
"Date & Time" );
87 case QMetaType::Type::QUrl:
88 return QObject::tr(
"URL" );
89 case QMetaType::Type::QLocale:
90 return QObject::tr(
"Locale" );
91 case QMetaType::Type::QRect:
92 case QMetaType::Type::QRectF:
93 return QObject::tr(
"Rectangle" );
94 case QMetaType::Type::QSize:
95 case QMetaType::Type::QSizeF:
96 return QObject::tr(
"Size" );
97 case QMetaType::Type::QLine:
98 case QMetaType::Type::QLineF:
99 return QObject::tr(
"Line" );
100 case QMetaType::Type::QPoint:
101 case QMetaType::Type::QPointF:
102 return QObject::tr(
"Point" );
103 case QMetaType::Type::QRegularExpression:
104 return QObject::tr(
"Regular Expression" );
105 case QMetaType::Type::QVariantHash:
106 return QObject::tr(
"Hash" );
107 case QMetaType::Type::QEasingCurve:
108 return QObject::tr(
"Easing Curve" );
109 case QMetaType::Type::QUuid:
110 return QObject::tr(
"UUID" );
111 case QMetaType::Type::QModelIndex:
112 case QMetaType::Type::QPersistentModelIndex:
113 return QObject::tr(
"Model Index" );
114 case QMetaType::Type::QFont:
115 return QObject::tr(
"Font" );
116 case QMetaType::Type::QPixmap:
117 return QObject::tr(
"Pixmap" );
118 case QMetaType::Type::QBrush:
119 return QObject::tr(
"Brush" );
120 case QMetaType::Type::QColor:
121 return QObject::tr(
"Color" );
122 case QMetaType::Type::QPalette:
123 return QObject::tr(
"Palette" );
124 case QMetaType::Type::QImage:
125 return QObject::tr(
"Image" );
126 case QMetaType::Type::QPolygon:
127 case QMetaType::Type::QPolygonF:
128 return QObject::tr(
"Polygon" );
129 case QMetaType::Type::QRegion:
130 return QObject::tr(
"Region" );
131 case QMetaType::Type::QBitmap:
132 return QObject::tr(
"Bitmap" );
133 case QMetaType::Type::QCursor:
134 return QObject::tr(
"Cursor" );
135 case QMetaType::Type::QKeySequence:
136 return QObject::tr(
"Key Sequence" );
137 case QMetaType::Type::QPen:
138 return QObject::tr(
"Pen" );
139 case QMetaType::Type::QTextLength:
140 return QObject::tr(
"Text Length" );
141 case QMetaType::Type::QTextFormat:
142 return QObject::tr(
"Text Format" );
143 case QMetaType::Type::QMatrix4x4:
144 return QObject::tr(
"Matrix" );
145 case QMetaType::Type::QTransform:
146 return QObject::tr(
"Transform" );
147 case QMetaType::Type::QVector2D:
148 case QMetaType::Type::QVector3D:
149 case QMetaType::Type::QVector4D:
150 return QObject::tr(
"Vector" );
151 case QMetaType::Type::QQuaternion:
152 return QObject::tr(
"Quaternion" );
153 case QMetaType::Type::QIcon:
154 return QObject::tr(
"Icon" );
155 case QMetaType::Type::QSizePolicy:
156 return QObject::tr(
"Size Policy" );
172 ( void )silenceNullWarnings;
175 if ( variant.isNull() || !variant.isValid() )
178 switch ( variant.userType() )
180 case QMetaType::Type::UnknownType:
181 case QMetaType::Type::Bool:
182 case QMetaType::Type::Int:
183 case QMetaType::Type::UInt:
184 case QMetaType::Type::LongLong:
185 case QMetaType::Type::ULongLong:
186 case QMetaType::Type::Double:
187 case QMetaType::Type::QVariantMap:
188 case QMetaType::Type::QVariantList:
189 case QMetaType::Type::QStringList:
190 case QMetaType::Type::QUrl:
191 case QMetaType::Type::QLocale:
192 case QMetaType::Type::QRegularExpression:
193 case QMetaType::Type::QVariantHash:
194 case QMetaType::Type::QEasingCurve:
195 case QMetaType::Type::QModelIndex:
196 case QMetaType::Type::QPersistentModelIndex:
200 case QMetaType::Type::QDate:
201 if ( variant.toDate().isNull() )
203 if ( !silenceNullWarnings )
205 QgsDebugError( QStringLiteral(
"NULL QDateTime was stored in a QVariant -- stop it! Always use an invalid QVariant() instead." ) );
210 case QMetaType::Type::QTime:
211 if ( variant.toTime().isNull() )
213 if ( !silenceNullWarnings )
215 QgsDebugError( QStringLiteral(
"NULL QTime was stored in a QVariant -- stop it! Always use an invalid QVariant() instead." ) );
220 case QMetaType::Type::QDateTime:
221 if ( variant.toDate().isNull() )
223 if ( !silenceNullWarnings )
225 QgsDebugError( QStringLiteral(
"NULL QDate was stored in a QVariant -- stop it! Always use an invalid QVariant() instead." ) );
230 case QMetaType::Type::QChar:
231 if ( variant.toChar().isNull() )
233 if ( !silenceNullWarnings )
235 QgsDebugError( QStringLiteral(
"NULL QChar was stored in a QVariant -- stop it! Always use an invalid QVariant() instead." ) );
240 case QMetaType::Type::QString:
241 if ( variant.toString().isNull() )
243 if ( !silenceNullWarnings )
245 QgsDebugError( QStringLiteral(
"NULL QString was stored in a QVariant -- stop it! Always use an invalid QVariant() instead." ) );
250 case QMetaType::Type::QByteArray:
251 if ( variant.toByteArray().isNull() )
253 if ( !silenceNullWarnings )
255 QgsDebugError( QStringLiteral(
"NULL QByteArray was stored in a QVariant -- stop it! Always use an invalid QVariant() instead." ) );
260 case QMetaType::Type::QBitArray:
261 if ( variant.toBitArray().isNull() )
263 if ( !silenceNullWarnings )
265 QgsDebugError( QStringLiteral(
"NULL QBitArray was stored in a QVariant -- stop it! Always use an invalid QVariant() instead." ) );
270 case QMetaType::Type::QRect:
271 if ( variant.toRect().isNull() )
273 if ( !silenceNullWarnings )
275 QgsDebugError( QStringLiteral(
"NULL QRect was stored in a QVariant -- stop it! Always use an invalid QVariant() instead." ) );
280 case QMetaType::Type::QRectF:
281 if ( variant.toRectF().isNull() )
283 if ( !silenceNullWarnings )
285 QgsDebugError( QStringLiteral(
"NULL QRectF was stored in a QVariant -- stop it! Always use an invalid QVariant() instead." ) );
290 case QMetaType::Type::QSize:
291 if ( variant.toSize().isNull() )
293 if ( !silenceNullWarnings )
295 QgsDebugError( QStringLiteral(
"NULL QSize was stored in a QVariant -- stop it! Always use an invalid QVariant() instead." ) );
300 case QMetaType::Type::QSizeF:
301 if ( variant.toSizeF().isNull() )
303 if ( !silenceNullWarnings )
305 QgsDebugError( QStringLiteral(
"NULL QSizeF was stored in a QVariant -- stop it! Always use an invalid QVariant() instead." ) );
310 case QMetaType::Type::QLine:
311 if ( variant.toLine().isNull() )
313 if ( !silenceNullWarnings )
315 QgsDebugError( QStringLiteral(
"NULL QLine was stored in a QVariant -- stop it! Always use an invalid QVariant() instead." ) );
320 case QMetaType::Type::QLineF:
321 if ( variant.toLineF().isNull() )
323 if ( !silenceNullWarnings )
325 QgsDebugError( QStringLiteral(
"NULL QLineF was stored in a QVariant -- stop it! Always use an invalid QVariant() instead." ) );
330 case QMetaType::Type::QPoint:
331 if ( variant.toPoint().isNull() )
333 if ( !silenceNullWarnings )
335 QgsDebugError( QStringLiteral(
"NULL QPoint was stored in a QVariant -- stop it! Always use an invalid QVariant() instead." ) );
340 case QMetaType::Type::QPointF:
341 if ( variant.toPointF().isNull() )
343 if ( !silenceNullWarnings )
345 QgsDebugError( QStringLiteral(
"NULL QPointF was stored in a QVariant -- stop it! Always use an invalid QVariant() instead." ) );
350 case QMetaType::Type::QUuid:
351 if ( variant.toUuid().isNull() )
353 if ( !silenceNullWarnings )
355 QgsDebugError( QStringLiteral(
"NULL QUuid was stored in a QVariant -- stop it! Always use an invalid QVariant() instead." ) );
360 case QMetaType::Type::QPixmap:
361 if ( variant.value< QPixmap >().isNull() )
363 if ( !silenceNullWarnings )
365 QgsDebugError( QStringLiteral(
"NULL QPixmap was stored in a QVariant -- stop it! Always use an invalid QVariant() instead." ) );
370 case QMetaType::Type::QImage:
371 if ( variant.value< QImage >().isNull() )
373 if ( !silenceNullWarnings )
375 QgsDebugError( QStringLiteral(
"NULL QImage was stored in a QVariant -- stop it! Always use an invalid QVariant() instead." ) );
380 case QMetaType::Type::QRegion:
381 if ( variant.value< QRegion >().isNull() )
383 if ( !silenceNullWarnings )
385 QgsDebugError( QStringLiteral(
"NULL QRegion was stored in a QVariant -- stop it! Always use an invalid QVariant() instead." ) );
390 case QMetaType::Type::QBitmap:
391 if ( variant.value< QBitmap >().isNull() )
393 if ( !silenceNullWarnings )
395 QgsDebugError( QStringLiteral(
"NULL QBitmap was stored in a QVariant -- stop it! Always use an invalid QVariant() instead." ) );
400 case QMetaType::Type::QIcon:
401 if ( variant.value< QIcon >().isNull() )
403 if ( !silenceNullWarnings )
405 QgsDebugError( QStringLiteral(
"NULL QIcon was stored in a QVariant -- stop it! Always use an invalid QVariant() instead." ) );
410 case QMetaType::Type::QVector2D:
411 if ( variant.value< QVector2D >().isNull() )
413 if ( !silenceNullWarnings )
415 QgsDebugError( QStringLiteral(
"NULL QVector2D was stored in a QVariant -- stop it! Always use an invalid QVariant() instead." ) );
420 case QMetaType::Type::QVector3D:
421 if ( variant.value< QVector3D >().isNull() )
423 if ( !silenceNullWarnings )
425 QgsDebugError( QStringLiteral(
"NULL QVector3D was stored in a QVariant -- stop it! Always use an invalid QVariant() instead." ) );
430 case QMetaType::Type::QVector4D:
431 if ( variant.value< QVector4D >().isNull() )
433 if ( !silenceNullWarnings )
435 QgsDebugError( QStringLiteral(
"NULL QVector4D was stored in a QVariant -- stop it! Always use an invalid QVariant() instead." ) );
440 case QMetaType::Type::QQuaternion:
441 if ( variant.value< QQuaternion >().isNull() )
443 if ( !silenceNullWarnings )
445 QgsDebugError( QStringLiteral(
"NULL QQuaternion was stored in a QVariant -- stop it! Always use an invalid QVariant() instead." ) );
451 case QMetaType::Type::QColor:
452 case QMetaType::Type::QFont:
453 case QMetaType::Type::QBrush:
454 case QMetaType::Type::QPolygon:
455 case QMetaType::Type::QPalette:
456 case QMetaType::Type::QCursor:
457 case QMetaType::Type::QKeySequence:
458 case QMetaType::Type::QPen:
459 case QMetaType::Type::QTextLength:
460 case QMetaType::Type::QPolygonF:
461 case QMetaType::Type::QTextFormat:
462 case QMetaType::Type::QTransform:
463 case QMetaType::Type::QMatrix4x4:
464 case QMetaType::Type::QSizePolicy:
465 case QMetaType::Type::User:
506 case QMetaType::Bool:
508 case QMetaType::UInt:
509 case QMetaType::LongLong:
510 case QMetaType::ULongLong:
511 case QMetaType::Double:
512 case QMetaType::QChar:
513 case QMetaType::QVariantMap:
514 case QMetaType::QVariantList:
515 case QMetaType::QString:
516 case QMetaType::QStringList:
517 case QMetaType::QByteArray:
518 case QMetaType::QBitArray:
519 case QMetaType::QDate:
520 case QMetaType::QTime:
521 case QMetaType::QDateTime:
522 case QMetaType::QUrl:
523 case QMetaType::QLocale:
524 case QMetaType::QRect:
525 case QMetaType::QRectF:
526 case QMetaType::QSize:
527 case QMetaType::QSizeF:
528 case QMetaType::QLine:
529 case QMetaType::QLineF:
530 case QMetaType::QPoint:
531 case QMetaType::QPointF:
532 case QMetaType::QRegularExpression:
533 case QMetaType::QVariantHash:
534 case QMetaType::QEasingCurve:
535 case QMetaType::QUuid:
536 case QMetaType::QModelIndex:
537 case QMetaType::QPersistentModelIndex:
538 case QMetaType::QFont:
539 case QMetaType::QPixmap:
540 case QMetaType::QBrush:
541 case QMetaType::QColor:
542 case QMetaType::QPalette:
543 case QMetaType::QImage:
544 case QMetaType::QPolygon:
545 case QMetaType::QRegion:
546 case QMetaType::QBitmap:
547 case QMetaType::QCursor:
548 case QMetaType::QKeySequence:
549 case QMetaType::QPen:
550 case QMetaType::QTextLength:
551 case QMetaType::QTextFormat:
552 case QMetaType::QTransform:
553 case QMetaType::QMatrix4x4:
554 case QMetaType::QVector2D:
555 case QMetaType::QVector3D:
556 case QMetaType::QVector4D:
557 case QMetaType::QQuaternion:
558 case QMetaType::QPolygonF:
559 case QMetaType::QIcon:
560 case QMetaType::QSizePolicy:
561 case QMetaType::UnknownType:
562 case QMetaType::User:
563 return static_cast< QVariant::Type
>( metaType );
567 case QMetaType::Long:
568 return QVariant::Type::LongLong;
570 case QMetaType::ULong:
571 return QVariant::Type::ULongLong;
573 case QMetaType::Char:
574#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
575 case QMetaType::Char16:
576 case QMetaType::Char32:
578 case QMetaType::Short:
579 case QMetaType::SChar:
580 return QVariant::Type::Int;
582 case QMetaType::UShort:
583 case QMetaType::UChar:
584 return QVariant::Type::UInt;
586 case QMetaType::Float:
587#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
588 case QMetaType::Float16:
590 return QVariant::Type::Double;
593 case QMetaType::Nullptr:
594 case QMetaType::QCborSimpleType:
595 case QMetaType::Void:
596 case QMetaType::VoidStar:
597 case QMetaType::QVariant:
598 case QMetaType::QJsonValue:
599 case QMetaType::QJsonObject:
600 case QMetaType::QJsonArray:
601 case QMetaType::QJsonDocument:
602 case QMetaType::QCborValue:
603 case QMetaType::QCborArray:
604 case QMetaType::QCborMap:
605 case QMetaType::QObjectStar:
606#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
607 case QMetaType::QVariantPair:
609 case QMetaType::QByteArrayList:
610 case QMetaType::QColorSpace:
617 return QVariant::Type::UserType;