aboutsummaryrefslogtreecommitdiffstats
path: root/qt-qml/tests/manual/qml-syntax/others.qml
blob: d4ae8ff194f90ceec13c4a97b536c48a0047c513 (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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
// Copyright (C) 2024 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only

// enum
Text {
    enumm TextType {
        Normal,
        Heading = 2,
        Contents
    }

    property int textType: MyText.TextType.Normal

    font.bold: textType === MyText.TextType.Heading
    font.pixelSize: textType === MyText.TextType.Heading ? 24 : 12
}

// inline component
Window {
    width: 300
    height: 200
    visible: true

    PushButtonInline { x: 50; y: 20 }
    PushButtonInline { x: 50; y: 100 }

    component PushButtonInline: Rectangle {
        id: _rect
        color: "skyblue"
        border.color: "lightgray"
        implicitWidth: 150
        implicitHeight: 60
    }
}

// attached prop
ListView {
    delegate: Item {
        id: _delegate
        width: 100; height: 30

        Rectangle {
            width: 100; height: 30
            color: _delegate.ListView.isCurrentItem ? "red" : "yellow" // correct
        }
    }
}

// string
Item {
    prop1: "value1"
    prop2: 'value2'
    prop3: `${prop1} abcd` + `this is a ${prop2} value.`

    Component.onCompleted: {
        // single line
        console.log("string text line ");
        console.log('string text line ');
        console.log(`string text line with ${a+b} and ${prop1}.`);

        // multiple line
        console.log(`string text line with ${a+b} and ${prop1}.
            the second line`);
    }
}

// comment
// This is a line comment

Item { // This is a comment
}

/*
  This is a block comment
*/

/*!
  This is a block comment
*/

// some helpers for user convenience
Item {
  // NOTE note entry
  // TODO todo entry
  // DEBUG debug entry
  // XXX xxx entry
  // BUG bug entry
  // FIXME fixme entry
  // WARNING warning entry
}