diff options
| author | Ulf Hermann <ulf.hermann@qt.io> | 2023-08-14 16:03:05 +0200 |
|---|---|---|
| committer | Ulf Hermann <ulf.hermann@qt.io> | 2023-08-24 12:39:43 +0200 |
| commit | 72e9f475268dac1543c8cd17510dbf9a57783a76 (patch) | |
| tree | 68e3284fbb0bda5f85c194e9612ed941d1b9ecd9 /tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp | |
| parent | c86c13d491ec80cbdecba513959ca481a508cb72 (diff) | |
QmlCompiler: Allow write-back to members of objects
This covers recursive write-back, but not write-back to members of
singletons or attached types, write-back of lists.
Task-number: QTBUG-116011
Change-Id: I6d33fae3bf9fdaed8d696a708124e0a707ecb07e
Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp')
| -rw-r--r-- | tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp index 881253f3ea..6792947056 100644 --- a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp +++ b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp @@ -208,6 +208,7 @@ private slots: void variantlist(); void voidConversion(); void voidFunction(); + void writeBack(); }; static QByteArray arg1() @@ -4219,6 +4220,24 @@ void tst_QmlCppCodegen::voidFunction() QCOMPARE(object->objectName(), u"barbar"_s); } +void tst_QmlCppCodegen::writeBack() +{ + QQmlEngine engine; + QQmlComponent component(&engine, QUrl(u"qrc:/qt/qml/TestTypes/writeback.qml"_s)); + QVERIFY2(component.isReady(), qPrintable(component.errorString())); + QScopedPointer<QObject> object(component.create()); + QVERIFY(!object.isNull()); + + Person *person = qobject_cast<Person *>(object.data()); + QVERIFY(person); + QCOMPARE(person->area(), QRectF(4, 5, 16, 17)); + QCOMPARE(person->property("inner").toInt(), 99); + + Person *shadowable = person->property("shadowable").value<Person *>(); + QVERIFY(shadowable); + QCOMPARE(shadowable->area(), QRectF(40, 50, 16, 17)); +} + QTEST_MAIN(tst_QmlCppCodegen) #include "tst_qmlcppcodegen.moc" |
