on 1600295 help sign in
99 lines 2.5 kB history raw
1import QtQuick 2.0
2import ListViewWithPageHeader 0.1
4Rectangle {
5 width: 300
6 height: 542
7 color: "lightblue"
9 focus: true
10 Keys.onPressed: {
11 if (event.key == Qt.Key_B) {
12 listView.positionAtBeginning()
13 } else if (event.key == Qt.Key_1) {
14 animalsModel.setProperty(0, "size", 400);
15 } else if (event.key == Qt.Key_2) {
16 animalsModel.setProperty(1, "size", 400);
17 } else if (event.key == Qt.Key_3) {
18 animalsModel.setProperty(1, "size", 10);
19 } else if (event.key == Qt.Key_H) {
20 listView.headerItem.height = 100
21 } else if (event.key == Qt.Key_D) {
22 listView.delegate = otherRect
23 } else if (event.key == Qt.Key_F) {
24 listView.header = null
25 }
26 }
29 ListModel {
30 id: model
32 function insertItem(index, size) {
33 insert(index, { size: size });
34 }
36 function removeItems(index, count) {
37 remove(index, count);
38 }
40 function moveItems(indexFrom, indexTo, count) {
41 move(indexFrom, indexTo, count);
42 }
44 ListElement { size: 150 }
45 ListElement { size: 200 }
46 ListElement { size: 350 }
47 ListElement { size: 350 }
48 ListElement { size: 350 }
49 ListElement { size: 350 }
50 }
52 Component {
53 id: otherRect
54 Rectangle {
55 height: 35
56 width: parent.width
57 color: index % 2 == 0 ? "yellow" : "purple"
58 }
59 }
61 ListViewWithPageHeader {
62 id: listView
63 width: parent.width
64 anchors.top: parent.top
65 anchors.bottom: parent.bottom
66 model: model
67 delegate: Rectangle {
68 property bool timerDone: false
69 width: parent.width - 20
70 x: 10
71 color: index % 2 == 0 ? "red" : "blue"
72 height: timerDone ? size : 350
73 Text {
74 text: index
75 }
76 Timer {
77 id: sizeTimer
78 interval: 10;
79 onTriggered: {
80 timerDone = true
81 }
82 }
83 Component.onCompleted: {
84 sizeTimer.start()
85 }
86 }
88 pageHeader: Rectangle {
89 color: "transparent"
90 width: parent.width
91 height: 50
92 Text {
93 anchors.fill: parent
94 text: "APPS"
95 font.pixelSize: 40
96 }
97 }
98 }