aboutsummaryrefslogtreecommitdiffstats
path: root/tests/manual/quickcontrols/testbench/ExampleContainer.qml
blob: 19dbb9a41c0b429ec083cfb7330b1989849359d0 (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
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause

import QtQuick
import QtQuick.Controls
import QtQuick.Layouts

Frame {
    id: container

    property var controlMetaObject

    ColumnLayout {
        id: exampleLayout
        anchors.centerIn: parent

        Label {
            text: !exampleLoader.active ? qsTr("Show example") : qsTr("Hide example")

            Layout.alignment: Qt.AlignHCenter

            MouseArea {
                anchors.fill: parent
                onClicked: exampleLoader.active = !exampleLoader.active
            }
        }

        Loader {
            id: exampleLoader
            active: false
            sourceComponent: controlMetaObject ? controlMetaObject.exampleComponent : null

            Layout.preferredHeight: active ? item.implicitHeight : 0
        }
    }
}