aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qmltest/buttonclick/Button.qml
blob: 0dd684f7803ccb5823e78b4b6be13c40c35e105d (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) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0

import QtQuick 2.0

Rectangle {
    id: container

    property string text: "Button"

    signal clicked(int x, int y)

    width: buttonLabel.width + 20; height: buttonLabel.height + 5
    border { width: 1; color: "black" }
    smooth: true
    radius: 8

    // color the button with a gradient
    gradient: Gradient {
        GradientStop { position: 0.0; color: "blue" }
        GradientStop { position: 1.0; color: "lightblue" }
    }

    MouseArea {
        id: mouseArea
        anchors.fill: parent
        onClicked: container.clicked(mouse.x, mouse.y);
    }

    Text {
        id: buttonLabel
        anchors.centerIn: container
        color: "white"
        text: container.text
    }
}