diff options
author | Shawn Rutledge <shawn.rutledge@qt.io> | 2020-06-10 13:10:16 +0200 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2020-06-10 18:55:43 +0200 |
commit | 9eabb32822461be292dbf5728274348d0da361cf (patch) | |
tree | 95789350f9fd1c18322a97ca0e243b892eb37fc4 /tests/auto/quick/qquickpathview | |
parent | 880ce0210406ff51d9c3a164ae95bcc43e020e8b (diff) |
Modernize tst_QQuickPathView::treeModel()
- Don't use context properties: a singleton is better
- Use required properties to declare dependendencies
Change-Id: I10a0a301e0a397b1d4fc9edf804eea3499c79025
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tests/auto/quick/qquickpathview')
-rw-r--r-- | tests/auto/quick/qquickpathview/data/treemodel.qml | 13 | ||||
-rw-r--r-- | tests/auto/quick/qquickpathview/tst_qquickpathview.cpp | 7 |
2 files changed, 12 insertions, 8 deletions
diff --git a/tests/auto/quick/qquickpathview/data/treemodel.qml b/tests/auto/quick/qquickpathview/data/treemodel.qml index b1e06f47d2..a39b4db6bf 100644 --- a/tests/auto/quick/qquickpathview/data/treemodel.qml +++ b/tests/auto/quick/qquickpathview/data/treemodel.qml @@ -1,5 +1,6 @@ -import QtQuick 2.0 -import QtQml.Models 2.12 +import QtQuick 2.15 +import QtQml.Models 2.15 +import Qt.treemodel PathView { width: 320 @@ -9,8 +10,12 @@ PathView { } model: DelegateModel { id: vdm - model: myModel - delegate: Text { objectName: "wrapper"; text: display } + model: TreeModelCpp + delegate: Text { + required property string display + objectName: "wrapper" + text: display + } } path: Path { diff --git a/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp b/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp index 0d2810b519..da350e6a39 100644 --- a/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp +++ b/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp @@ -1672,13 +1672,12 @@ void tst_QQuickPathView::flickNClick() // QTBUG-77173 void tst_QQuickPathView::treeModel() { - QScopedPointer<QQuickView> window(createView()); - window->show(); - QStandardItemModel model; initStandardTreeModel(&model); - window->engine()->rootContext()->setContextProperty("myModel", &model); + qmlRegisterSingletonInstance("Qt.treemodel", 1, 0, "TreeModelCpp", &model); + QScopedPointer<QQuickView> window(createView()); + window->show(); window->setSource(testFileUrl("treemodel.qml")); QQuickPathView *pathview = qobject_cast<QQuickPathView*>(window->rootObject()); |