aboutsummaryrefslogtreecommitdiffstats
path: root/qt-qml/tests/manual/qml-syntax/attribute.qml
blob: e90e1567ef6a4caa2528ca4ea5bbea9937c5d61a (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
59
60
61
62
63
64
// Copyright (C) 2024 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only

Rectangle {
    // object case
    gradient: Gradient {
        GradientStop { position: 0.0; color: "yellow" }
        GradientStop { position: 1.0; color: "green" }
    }

    // list of objects
    children: [
        Item { value: 1 },
        Item { value: 2 },
        T.Item { value: 3 }
    ]

    // list of js expressions
    values: [
        1, 2, 3, 4,
        2*20, Math.PI, calc(20)
    ]

    // js block
    width: { return 100; }
    width: {
        const val = 3;
        const result = val * 2;

        // comment
        return result / Math.PI;
    }

    // js expression
    width: 100 * 2;
    width: height / 2
    width: 100
    width: 100;
    width: 100; height: 200
    width: 100; height: 200;
    color: "red"
    color: Qt.rgba(100, 100, 100, 100)
    opacity: 1.2
    visible: true
    visible: false
    values: [1, 2, 3, 4]

    // group
    anchors.fill: parent
    anchors {
        left: other.right // comment
        right: parent.right
        // comment
        top: parent.top
    }

    // multi-line
    color: Qt.rgba(
        100,
        100,
        100,
        Math.random()
    )
}