aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/doc/snippets/qmltc/MyButton.qml
blob: 5efbd7f88dae3d0d62f2d929f67553c789794ebc (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
// Copyright (C) 2022 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause

import QtQuick

Rectangle {
    id: button
    property alias text: textItem.text
    signal clicked()

    readonly property color constantColor: "#63ACBE"
    color: mouseArea.pressed ? Qt.lighter(constantColor) : constantColor
    width: textItem.implicitWidth + 5
    height: textItem.implicitHeight + 5
    radius: 10

    Text {
        id: textItem
        font.pixelSize: 22
        color: "black"
        anchors.centerIn: button
    }

    MouseArea {
        id: mouseArea
        anchors.fill: button
        anchors.margins: -5
        onClicked: function(event) { button.clicked(); }
    }
}