summaryrefslogtreecommitdiffstats
path: root/examples/sensors/qmlqtsensors5/SelectionButton.qml
blob: e258d5e1c86d6bef405f3520d7e186583194300d (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
import QtQuick 2.0

Rectangle {
    id: button
    width: 100
    height: 25
    property alias text: t.text
    property bool checked
    signal clicked

    Image{
        id: image
        x: 0
        width: 15
        height: 15
        source: (button.checked == true ? "checked.gif" : "unchecked.gif")
    }

    Text{
        x: image.x + image.width + 10
        id: t
    }

    MouseArea{
        anchors.fill: button
        onClicked: {
            setCheck(true);
            button.clicked();
        }
    }

    function setCheck(val)
    {
        checked = val;
        image.source = (button.checked == true ? "checked.gif" : "unchecked.gif");
    }
}