-
Notifications
You must be signed in to change notification settings - Fork 0
/
Test.qml
76 lines (63 loc) · 1.6 KB
/
Test.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import QtQuick 2.0
import QtQuick 2.0
Rectangle {
width: 360
height: 360
ListModel {
id: dataModel
ListElement {
color: "orange"
text: "first"
}
ListElement {
color: "lightgreen"
text: "second"
}
ListElement {
color: "orchid"
text: "third"
}
ListElement {
color: "tomato"
text: "fourth"
}
}
ListView {
id: view
anchors.margins: 10
anchors.fill: parent
spacing: 10
model: dataModel
clip: true
highlight: Rectangle {
color: "skyblue"
}
highlightFollowsCurrentItem: true
delegate: Item {
id: listDelegate
property var view: ListView.view
property var isCurrent: ListView.isCurrentItem
width: view.width
height: 40
Rectangle {
anchors.margins: 5
anchors.fill: parent
radius: height / 2
color: model.color
border {
color: "black"
width: 1
}
Text {
anchors.centerIn: parent
renderType: Text.NativeRendering
text: "%1%2".arg(model.text).arg(isCurrent ? " *" : "")
}
MouseArea {
anchors.fill: parent
onClicked: view.currentIndex = model.index
}
}
}
}
}