summaryrefslogtreecommitdiffstats
path: root/examples/declarative/tutorials/samegame/samegame1/Button.qml
blob: 8ad7c0fd8f572ae866f528abe80896125cec043a (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
//![0]
import Qt 4.7

Rectangle {
    id: container

    signal clicked
    property string text: "Button"

    color: activePalette.button; smooth: true
    width: buttonLabel.width + 20; height: buttonLabel.height + 6
    border.width: 1; border.color: Qt.darker(activePalette.button); radius: 8;

    gradient: Gradient {
        GradientStop {
            position: 0.0
            color: if (mouseArea.pressed) { activePalette.dark } else { activePalette.light }
        }
        GradientStop { position: 1.0; color: activePalette.button }
    }

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

    Text {
        id: buttonLabel; text: container.text; anchors.centerIn: container; color: activePalette.buttonText
    }
}
//![0]