aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/doc/snippets/qml/repeaters/repeater.qml
blob: b1cee3ea8d2ee9d99c88cf0bbe1b1659b1987fdb (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
53
54
55
56
57
58
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause

//! [import]
import QtQuick
//! [import]

Row {

//! [simple]
Row {
    Repeater {
        model: 3
        Rectangle {
            width: 100; height: 40
            border.width: 1
            color: "yellow"
        }
    }
}
//! [simple]

//! [index]
Column {
    Repeater {
        model: 10
        Text {
            required property int index
            text: "I'm item " + index
        }
    }
}
//! [index]

//! [modeldata]
Column {
    Repeater {
        model: ["apples", "oranges", "pears"]
        Text {
            required property string modelData
            text: "Data: " + modelData
        }
    }
}
//! [modeldata]

//! [layout]
Row {
    Rectangle { width: 10; height: 20; color: "red" }
    Repeater {
        model: 10
        Rectangle { width: 20; height: 20; radius: 10; color: "green" }
    }
    Rectangle { width: 10; height: 20; color: "blue" }
}
//! [layout]

}