aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/doc/snippets/qml/reusablecomponents/focusbutton.qml
blob: be1feabe67c6af95a492be8fc7505754e7793430 (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
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
//! [document]
//contents of focusbutton.qml
import QtQuick

//! [parent begin]
FocusScope {
//! [parent begin]

    //! [expose visuals]
    //FocusScope needs to bind to visual properties of the children
    property alias color: button.color
    x: button.x; y: button.y
    width: button.width; height: button.height
    //! [expose visuals]

    //! [rectangle begin]
    Rectangle {
    //! [rectangle begin]
        id: button
    //! [properties]
        width: 145; height: 60
        color: "blue"
        antialiasing: true; radius: 9
        property alias text: label.text
    //! [properties]
        border {color: "#B9C5D0"; width: 1}

        gradient: Gradient {
            GradientStop {color: "#CFF7FF"; position: 0.0}
            GradientStop {color: "#99C0E5"; position: 0.57}
            GradientStop {color: "#719FCB"; position: 0.9}
        }

        Text {
            id: label
            anchors.centerIn: parent
            text: "Click Me!"
            font.pointSize: 12
            color: "blue"
        }

        MouseArea {
            anchors.fill: parent
            onClicked: console.log(text + " clicked")
        }
    //! [rectangle end]
    }
    //! [rectangle end]
//! [parent end]
}
//! [parent end]

//! [document]

//! [ellipses]
    //...
//! [ellipses]