blob: 366b20b0295169335990f920b588b6d291da7c3a (
plain)
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
|
import QtQuick
ListView {
id: root
function allDelegates(valueSelector) {
let sum = 0;
for (let i = 0; i < root.count; i++)
sum += valueSelector(root.itemAtIndex(i));
return sum;
}
readonly property bool isXReset: allDelegates(function(item) { return item?.x ?? 0; }) === 0
readonly property bool isYReset: allDelegates(function(item) { return item?.y ?? 0; }) === 0
width: 500
height: 500
delegate: Rectangle {
width: root.width
height: root.height
color: c
}
model: ListModel {
ListElement {
c: "red"
}
ListElement {
c: "green"
}
ListElement {
c: "blue"
}
ListElement {
c: "cyan"
}
ListElement {
c: "magenta"
}
ListElement {
c: "teal"
}
}
clip: true
orientation: ListView.Vertical
snapMode: ListView.SnapOneItem
highlightRangeMode: ListView.StrictlyEnforceRange
}
|