diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2022-07-25 14:24:19 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2022-07-26 21:17:28 +0200 |
commit | 6ea2a1cdb728635f9bd3cf239f751d4e88610881 (patch) | |
tree | 8db607732c7fcd1ea8dd4d0692f1d1046a4fa6a8 /tests/auto/qml/qmlcppcodegen | |
parent | aa9412615bf7cee3fdcfd3854ba73f4cb3ed93b7 (diff) |
QQmlListAccessor: Accept QQmlListProperty
So far we have only accepted QQmlListReference. However, we can also
pass a QQmlListProperty around as value.
Pick-to: 6.2 6.3 6.4
Fixes: QTBUG-105137
Change-Id: I7d4cd3048b62594298f91013c4cda5ec864a28df
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Diffstat (limited to 'tests/auto/qml/qmlcppcodegen')
-rw-r--r-- | tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt | 1 | ||||
-rw-r--r-- | tests/auto/qml/qmlcppcodegen/data/listPropertyAsModel.qml | 16 | ||||
-rw-r--r-- | tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp | 12 |
3 files changed, 29 insertions, 0 deletions
diff --git a/tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt b/tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt index 93b83d4f29..b9486c7a7b 100644 --- a/tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt +++ b/tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt @@ -106,6 +106,7 @@ set(qml_files layouts.qml library.js listIndices.qml + listPropertyAsModel.qml listlength.qml math.qml methods.qml diff --git a/tests/auto/qml/qmlcppcodegen/data/listPropertyAsModel.qml b/tests/auto/qml/qmlcppcodegen/data/listPropertyAsModel.qml new file mode 100644 index 0000000000..77a284d179 --- /dev/null +++ b/tests/auto/qml/qmlcppcodegen/data/listPropertyAsModel.qml @@ -0,0 +1,16 @@ +pragma Strict +import QtQuick + +Item { + Item { + id: child + Item {} + Item {} + Item {} + } + Repeater { + id: self + Item {} + Component.onCompleted: self.model = child.children + } +} diff --git a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp index 352660b6e3..80ea1952cd 100644 --- a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp +++ b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp @@ -133,6 +133,7 @@ private slots: void enumLookup(); void trivialSignalHandler(); void stringToByteArray(); + void listPropertyAsModel(); }; void tst_QmlCppCodegen::simpleBinding() @@ -2453,6 +2454,17 @@ void tst_QmlCppCodegen::stringToByteArray() QCOMPARE(person->name(), u"some data"_s); } +void tst_QmlCppCodegen::listPropertyAsModel() +{ + QQmlEngine engine; + QQmlComponent c(&engine, QUrl(u"qrc:/qt/qml/TestTypes/listPropertyAsModel.qml"_s)); + QVERIFY2(c.isReady(), qPrintable(c.errorString())); + QScopedPointer<QObject> o(c.create()); + + QQmlListReference children(o.data(), "children"); + QCOMPARE(children.count(), 5); +} + void tst_QmlCppCodegen::runInterpreted() { #ifdef Q_OS_ANDROID |