aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/doc/snippets/qml/reusablecomponents/component.qml
blob: ba70f0b9e24af42c2bc0b705148e8b6eb5089481 (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
// 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]
    id: screen
    width: 175; height: 175
    color: "lightgrey"

//! [define inline component]
    Component {
        id: inlinecomponent
        Rectangle {
            id: display
            width: 50; height: 50
            color: "blue"
        }
    }
//! [define inline component]
//! [create inline component]
    MouseArea {
        anchors.fill: parent
        onClicked: {
            inlinecomponent.createObject(parent)

            var second = inlinecomponent.createObject(parent)

            var third = inlinecomponent.createObject(parent)
            third.x = second.width + 10
            third.color = "red"
        }
    }
//! [create inline component]
//! [parent end]
}
//! [parent end]
//! [document]