summaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative/qmlparser/listItemDeleteSelf.qml
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/declarative/qmlparser/listItemDeleteSelf.qml')
-rw-r--r--tests/auto/declarative/qmlparser/listItemDeleteSelf.qml38
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/auto/declarative/qmlparser/listItemDeleteSelf.qml b/tests/auto/declarative/qmlparser/listItemDeleteSelf.qml
new file mode 100644
index 0000000..fa2e831
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/listItemDeleteSelf.qml
@@ -0,0 +1,38 @@
+import Qt 4.6
+
+Item {
+ ListModel {
+ id: FruitModel
+ ListElement {
+ name: "Apple"
+ cost: 2.45
+ }
+ ListElement {
+ name: "Orange"
+ cost: 3.25
+ }
+ ListElement {
+ name: "Banana"
+ cost: 1.95
+ }
+ }
+
+ Component {
+ id: FruitDelegate
+ Item {
+ width: 200; height: 50
+ Text { text: name }
+ Text { text: '$'+cost; anchors.right: parent.right }
+ MouseRegion {
+ anchors.fill: parent
+ onClicked: FruitModel.remove(index)
+ }
+ }
+ }
+
+ ListView {
+ model: FruitModel
+ delegate: FruitDelegate
+ anchors.fill: parent
+ }
+}