aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/doc/snippets/qml/listview.qml
blob: 948249f849d172dc2e4f4040268cb7c6b1019f58 (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
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause

//! [document]
import QtQuick

//! [parent begin]
Rectangle {
//! [parent begin]
    width: 175; height: 175; color: "white"

//! [model]
ListModel {
    id: petlist
    ListElement { type: "Cat" }
    ListElement { type: "Dog" }
    ListElement { type: "Mouse" }
    ListElement { type: "Rabbit" }
    ListElement { type: "Horse" }
}
//! [model]

//! [delegate]
Component {
    id: petdelegate
    Text {
        id: label
        font.pixelSize: 24
        text: index === 0 ? type + " (default)" : type

        required property int index
        required property string type
    }
}
//! [delegate]

//! [view]
ListView {
    id: view
    anchors.fill: parent

    model: petlist
    delegate: petdelegate
}
//! [view]

//! [parent end]
}
//! [parent end]
//! [document]