aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qmltest/listview/data/MultiDelegate3.qml
blob: a51dbbb49f8ae26c7206be31004393e35edcff29 (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) 2020 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause

import QtQuick 2.12
import QtQml.Models 2.12
import Qt.labs.qmlmodels 1.0

ListView {
    width: 400
    height: 400

    property var item1: QtObject {
        property string dataType: "rect"
        property color color: "red"
    }
    property var item2: QtObject {
        property string dataType: "text"
        property string text: "Hello world"
    }
    model: [ item1, item2 ]

    delegate: DelegateChooser {
        role: "dataType"
        DelegateChoice {
            roleValue: "rect"
            delegate: Rectangle {
                width: parent.width
                height: 50
                color: modelData.color
            }
        }
        DelegateChoice {
            roleValue: "text"
            delegate: Text {
                width: parent.width
                height: 50
                horizontalAlignment: Text.AlignHCenter
                verticalAlignment: Text.AlignVCenter
                text: modelData.text
            }
        }

        DelegateChoice {
            delegate: Item {
                    width: parent.width
                    height: 50
            }
        }
    }
}