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:
485 case QMetaType::Bool:
487 case QMetaType::UInt:
488 case QMetaType::LongLong:
489 case QMetaType::ULongLong:
490 case QMetaType::Double:
491 case QMetaType::QChar:
492 case QMetaType::QVariantMap:
493 case QMetaType::QVariantList:
494 case QMetaType::QString:
495 case QMetaType::QStringList:
496 case QMetaType::QByteArray:
497 case QMetaType::QBitArray:
498 case QMetaType::QDate:
499 case QMetaType::QTime:
500 case QMetaType::QDateTime:
501 case QMetaType::QUrl:
502 case QMetaType::QLocale:
503 case QMetaType::QRect:
504 case QMetaType::QRectF:
505 case QMetaType::QSize:
506 case QMetaType::QSizeF:
507 case QMetaType::QLine:
508 case QMetaType::QLineF:
509 case QMetaType::QPoint:
510 case QMetaType::QPointF:
511 case QMetaType::QRegularExpression:
512 case QMetaType::QVariantHash:
513 case QMetaType::QEasingCurve:
514 case QMetaType::QUuid:
515 case QMetaType::QModelIndex:
516 case QMetaType::QPersistentModelIndex:
517 case QMetaType::QFont:
518 case QMetaType::QPixmap:
519 case QMetaType::QBrush:
520 case QMetaType::QColor:
521 case QMetaType::QPalette:
522 case QMetaType::QImage:
523 case QMetaType::QPolygon:
524 case QMetaType::QRegion:
525 case QMetaType::QBitmap:
526 case QMetaType::QCursor:
527 case QMetaType::QKeySequence:
528 case QMetaType::QPen:
529 case QMetaType::QTextLength:
530 case QMetaType::QTextFormat:
531 case QMetaType::QTransform:
532 case QMetaType::QMatrix4x4:
533 case QMetaType::QVector2D:
534 case QMetaType::QVector3D:
535 case QMetaType::QVector4D:
536 case QMetaType::QQuaternion:
537 case QMetaType::QPolygonF:
538 case QMetaType::QIcon:
539 case QMetaType::QSizePolicy:
540 case QMetaType::UnknownType:
541 case QMetaType::User:
542 return static_cast< QVariant::Type
>( metaType );
546 case QMetaType::Long:
547 return QVariant::Type::LongLong;
549 case QMetaType::ULong:
550 return QVariant::Type::ULongLong;
552 case QMetaType::Char:
553#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
554 case QMetaType::Char16:
555 case QMetaType::Char32:
557 case QMetaType::Short:
558 case QMetaType::SChar:
559 return QVariant::Type::Int;
561 case QMetaType::UShort:
562 case QMetaType::UChar:
563 return QVariant::Type::UInt;
565 case QMetaType::Float:
566#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
567 case QMetaType::Float16:
569 return QVariant::Type::Double;
572 case QMetaType::Nullptr:
573 case QMetaType::QCborSimpleType:
574 case QMetaType::Void:
575 case QMetaType::VoidStar:
576 case QMetaType::QVariant:
577 case QMetaType::QJsonValue:
578 case QMetaType::QJsonObject:
579 case QMetaType::QJsonArray:
580 case QMetaType::QJsonDocument:
581 case QMetaType::QCborValue:
582 case QMetaType::QCborArray:
583 case QMetaType::QCborMap:
584 case QMetaType::QObjectStar:
585#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
586 case QMetaType::QVariantPair:
588 case QMetaType::QByteArrayList:
589 case QMetaType::QColorSpace:
596 return QVariant::Type::UserType;