diff options
author | Alexandru Croitor <alexandru.croitor@qt.io> | 2020-03-10 15:09:37 +0100 |
---|---|---|
committer | Alexandru Croitor <alexandru.croitor@qt.io> | 2020-03-12 15:03:03 +0100 |
commit | 26c5243491f495194f04b449128dae36118e28da (patch) | |
tree | 7fb14678a6fc9e44a10c9224d005e2cbdc6bcb63 /examples/quick/views/listview/dynamiclist.qml | |
parent | 1c7d264e3b2e9a2f0021786ea6967185f8282af0 (diff) | |
parent | c24c5baeda4101b0058689adf9200b77a722c3a2 (diff) |
Merge remote-tracking branch 'origin/dev' into wip/cmake
Conflicts:
dependencies.yaml
src/qml/qml/qqmlengine.cpp
Change-Id: I6a73fd1064286f4a2232de85c2ce7f80452d4641
Diffstat (limited to 'examples/quick/views/listview/dynamiclist.qml')
-rw-r--r-- | examples/quick/views/listview/dynamiclist.qml | 37 |
1 files changed, 28 insertions, 9 deletions
diff --git a/examples/quick/views/listview/dynamiclist.qml b/examples/quick/views/listview/dynamiclist.qml index bfc697d094..f37aab98e2 100644 --- a/examples/quick/views/listview/dynamiclist.qml +++ b/examples/quick/views/listview/dynamiclist.qml @@ -101,6 +101,11 @@ Rectangle { width: listView.width; height: 80 clip: true + required property int index + required property string name + required property real cost + required property var attributes + Column { id: arrows anchors { @@ -109,10 +114,16 @@ Rectangle { } Image { source: "content/pics/arrow-up.png" - MouseArea { anchors.fill: parent; onClicked: fruitModel.move(index, index-1, 1) } + MouseArea { + anchors.fill: parent + onClicked: fruitModel.move(delegateItem.index, delegateItem.index - 1, 1) + } } Image { source: "content/pics/arrow-down.png" - MouseArea { anchors.fill: parent; onClicked: fruitModel.move(index, index+1, 1) } + MouseArea { + anchors.fill: parent + onClicked: fruitModel.move(delegateItem.index, delegateItem.index + 1, 1) + } } } @@ -125,7 +136,7 @@ Rectangle { Text { anchors.horizontalCenter: parent.horizontalCenter - text: name + text: delegateItem.name font.pixelSize: 15 color: "white" } @@ -133,8 +144,12 @@ Rectangle { anchors.horizontalCenter: parent.horizontalCenter spacing: 5 Repeater { - model: attributes - Text { text: description; color: "White" } + model: delegateItem.attributes + Text { + required property string description + text: description + color: "White" + } } } } @@ -154,13 +169,13 @@ Rectangle { PressAndHoldButton { anchors.verticalCenter: parent.verticalCenter source: "content/pics/plus-sign.png" - onClicked: fruitModel.setProperty(index, "cost", cost + 0.25) + onClicked: fruitModel.setProperty(delegateItem.index, "cost", delegateItem.cost + 0.25) } Text { id: costText anchors.verticalCenter: parent.verticalCenter - text: '$' + Number(cost).toFixed(2) + text: '$' + Number(delegateItem.cost).toFixed(2) font.pixelSize: 15 color: "white" font.bold: true @@ -169,12 +184,16 @@ Rectangle { PressAndHoldButton { anchors.verticalCenter: parent.verticalCenter source: "content/pics/minus-sign.png" - onClicked: fruitModel.setProperty(index, "cost", Math.max(0,cost-0.25)) + onClicked: fruitModel.setProperty(delegateItem.index, "cost", + Math.max(0, delegateItem.cost - 0.25)) } Image { source: "content/pics/list-delete.png" - MouseArea { anchors.fill:parent; onClicked: fruitModel.remove(index) } + MouseArea { + anchors.fill: parent + onClicked: fruitModel.remove(delegateItem.index) + } } } } |