File indexing completed on 2024-05-26 04:43:03

0001 #include <QVariant>
0002 #include <QString>
0003 #include <QObject>
0004 
0005 struct SomeCustomType {
0006     int foo = 42;
0007 };
0008 Q_DECLARE_METATYPE(SomeCustomType)
0009 
0010 int main()
0011 {
0012     QObject myObj;
0013     QVariant v;
0014 
0015     v = QString::fromUtf8("KDevelop (QString)");
0016     v = QByteArray("KDevelop (QByteArray)");
0017 
0018     v = QVariant::fromValue(qint8(-8));
0019     v = QVariant::fromValue(quint8(8));
0020     v = QVariant::fromValue(qint16(-16));
0021     v = QVariant::fromValue(quint16(16));
0022     v = QVariant::fromValue(qint32(-32));
0023     v = QVariant::fromValue(quint32(32));
0024     v = QVariant::fromValue(qint64(-64));
0025     v = QVariant::fromValue(quint64(64));
0026 
0027     v = QVariant::fromValue(true);
0028 
0029     v = QVariant::fromValue(4.5f);
0030     v = QVariant::fromValue(42.5);
0031 
0032     v = QVariant::fromValue(&myObj);
0033 
0034     v = QVariant::fromValue(SomeCustomType());
0035 
0036     Q_UNUSED(v); // prevent compiler optimizing away unused object
0037     return 0;
0038 }