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-27 10:21:06 +0200 |
commit | cfb3438ecc3af26e8ad146ba0d8509315db028bb (patch) | |
tree | 3699c811df2152a381017d43d995c914218e075d /tests | |
parent | a60716ec7de718768b413767c9bde24ec0cc9503 (diff) |
QQmlListAccessor: Accept QQmlListProperty
So far we have only accepted QQmlListReference. However, we can also
pass a QQmlListProperty around as value.
Fixes: QTBUG-105137
Change-Id: I7d4cd3048b62594298f91013c4cda5ec864a28df
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
(cherry picked from commit 6ea2a1cdb728635f9bd3cf239f751d4e88610881)
Diffstat (limited to 'tests')
-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 8d7c494b11..d5711293b0 100644 --- a/tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt +++ b/tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt @@ -103,6 +103,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 3f6bb619a8..2d8c1b00c7 100644 --- a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp +++ b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp @@ -130,6 +130,7 @@ private slots: void badSequence(); void enumLookup(); void stringToByteArray(); + void listPropertyAsModel(); }; void tst_QmlCppCodegen::simpleBinding() @@ -2390,6 +2391,17 @@ void tst_QmlCppCodegen::stringToByteArray() QCOMPARE(person->name(), u"some data"_s); } +void tst_QmlCppCodegen::listPropertyAsModel() +{ + QQmlEngine engine; + QQmlComponent c(&engine, QUrl(u"qrc:/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 |