aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2023-08-24 16:02:00 +0200
committerUlf Hermann <ulf.hermann@qt.io>2023-08-25 20:36:46 +0200
commitf839171eefbba670536262fa3b847d24bfdc627b (patch)
tree0aef06db416563827580762930910022b7623086 /tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
parent555125416eb1a12e15dddb57207ce7d87751a64b (diff)
QmlCompiler: Allow creation of actual QVariantMaps from object literals
There are places where we need this: a, If the method in question actually takes a QVariantMap as argument. b, If the resulting value can be shadowed. In that case we expect a QVariant. The engine has to internally convert to the expected type then. Change-Id: Ic5b3faab4578d64ca757de644fe69660fd70e52a Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp')
-rw-r--r--tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
index e60d3b2505..40689c6634 100644
--- a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
+++ b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
@@ -206,6 +206,7 @@ private slots:
void variantMapLookup();
void variantReturn();
void variantlist();
+ void variantMap();
void voidConversion();
void voidFunction();
void writeBack();
@@ -4208,6 +4209,18 @@ void tst_QmlCppCodegen::variantlist()
QCOMPARE(things[1].toInt(), 30);
}
+void tst_QmlCppCodegen::variantMap()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, QUrl(u"qrc:/qt/qml/TestTypes/variantMap.qml"_s));
+ QVERIFY2(c.isReady(), qPrintable(c.errorString()));
+ QScopedPointer<QObject> o(c.create());
+ QVERIFY(o);
+
+ QCOMPARE(o->objectName(), "a b"_L1);
+ QCOMPARE(o->property("r"), QVariant::fromValue(QRectF(12, 13, 14, 15)));
+}
+
void tst_QmlCppCodegen::voidConversion()
{
QQmlEngine engine;