Ubuntu Pastebin

Paste from zub at Tue, 4 Aug 2015 20:05:12 +0000

Download as text
 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
import QtQuick 2.0
import Ubuntu.Components 1.2

MainView {
    applicationName: "tester.zub"

    width: units.gu(100)
    height: units.gu(75)

    Page {
        title: "Tester"

        Column {
            spacing: units.gu(1)
            anchors {
                margins: units.gu(2)
                fill: parent
            }

            ListModel {
                id: model
                ListElement { name: "foo" }
                ListElement { name: "bar" }
                ListElement { name: "baz" }
            }

            Label {
                text: "Label:"
            }

            ListView { // http://doc.qt.io/qt-5/qml-qtquick-listview.html
                model: model

                header: Label {
                    text: "HEADER"
                }
                footer: Label {
                    text: "FOOTER"
                }

                delegate: ListItem {
                    Label {
                        text: name
                    }
                    Component.onCompleted: console.log("Created item idx " + index + " [name=" + name + "]")
                }
                Component.onCompleted: console.log("List items: " + model.count)
            }
        }
    }
}
Download as text