diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2019-09-17 18:10:59 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2020-02-11 19:26:05 +0100 |
commit | 90b4528b846542bfa6f0723487315140b9de17b4 (patch) | |
tree | 9356c0e6b5a736b3228ca6793416d927432c101e /examples/quick/views/objectmodel | |
parent | 38c03709236f6a2114ace7adf1b6bdcdfe8e4e18 (diff) |
Avoid discouraged patterns in examples
In particular, use required properties where applicable, explicitly
import QtQml where we use it, avoid unqualified access into the root
scope of a component, use JavaScript functions with explicit parameters
as signal handlers.
Change-Id: I3eaaba47cc3c7a2a12d488e36f9eec145cedbb0e
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'examples/quick/views/objectmodel')
-rw-r--r-- | examples/quick/views/objectmodel/objectmodel.qml | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/examples/quick/views/objectmodel/objectmodel.qml b/examples/quick/views/objectmodel/objectmodel.qml index 8fc2f7c386..c9e4b8a5cd 100644 --- a/examples/quick/views/objectmodel/objectmodel.qml +++ b/examples/quick/views/objectmodel/objectmodel.qml @@ -70,21 +70,21 @@ Rectangle { color: "#FFFEF0" Text { text: "Page 1"; font.bold: true; anchors.centerIn: parent } - Component.onDestruction: if (printDestruction) print("destroyed 1") + Component.onDestruction: if (root.printDestruction) print("destroyed 1") } Rectangle { width: view.width; height: view.height color: "#F0FFF7" Text { text: "Page 2"; font.bold: true; anchors.centerIn: parent } - Component.onDestruction: if (printDestruction) print("destroyed 2") + Component.onDestruction: if (root.printDestruction) print("destroyed 2") } Rectangle { width: view.width; height: view.height color: "#F4F0FF" Text { text: "Page 3"; font.bold: true; anchors.centerIn: parent } - Component.onDestruction: if (printDestruction) print("destroyed 3") + Component.onDestruction: if (root.activeFocusprintDestruction) print("destroyed 3") } } @@ -112,6 +112,8 @@ Rectangle { model: itemModel.count Rectangle { + required property int index + width: 5; height: 5 radius: 3 color: view.currentIndex == index ? "blue" : "white" @@ -119,7 +121,7 @@ Rectangle { MouseArea { width: 20; height: 20 anchors.centerIn: parent - onClicked: view.currentIndex = index + onClicked: view.currentIndex = parent.index } } } |