-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathview2.qml
43 lines (39 loc) · 1.07 KB
/
view2.qml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import QtQuick 2.9
import QtQuick.Controls 2.2
ApplicationWindow {
visible: true
width: 640
height: 480
title: qsTr("List model")
ListModel {id: dataModel}
Column {
width: parent.width
height: parent.height
ListView {
id: listView
width: parent.widthgit
height: parent.height - addButton.height
spacing: 4
model: dataModel
delegate: Rectangle {
width: parent.width; height: 70; color: "blue"
Text {
anchors.centerIn: parent
text: model.text
}
MouseArea {
anchors.fill: parent
onClicked: dataModel.remove(model.index, 1)
}
}
}
Text {
id: addButton
text: "Add item"
MouseArea {
anchors.fill: parent
onClicked: dataModel.append({text: "Item #" + dataModel.count})
}
}
}
}