blob: 4be9dc72eac7553dd029b94cccb935c02fbe32c0 (
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
48
49
50
51
52
|
import Qt 4.6
Rectangle {
color: "white"
width: 800
height: 600
ListModel {
id: Model
ListElement { name: "1" }
ListElement { name: "2" }
ListElement { name: "3" }
ListElement { name: "4" }
ListElement { name: "5" }
ListElement { name: "6" }
ListElement { name: "7" }
ListElement { name: "8" }
ListElement { name: "9" }
}
Component {
id: VerticalDelegate
FocusScope {
id: Root
width: 50; height: 50;
Keys.onDigit9Pressed: console.log("Error - " + name)
Rectangle {
focus: true
Keys.onDigit9Pressed: console.log(name)
width: 50; height: 50;
color: Root.ListView.isCurrentItem?"red":"green"
Text { text: name; anchors.centerIn: parent }
}
}
}
ListView {
width: 800; height: 50; orientation: "Horizontal"
focus: true
model: Model
delegate: VerticalDelegate
preferredHighlightBegin: 100
preferredHighlightEnd: 101
highlightRangeMode: ListView.StrictlyEnforceRange
}
Text {
y: 100; x: 50
text: "Currently selected element should be red\nPressing \"9\" should print the number of the currently selected item\nBe sure to scroll all the way to the right, pause, and then all the way to the left."
}
}
|