Export Checkbox as separate qml file
[mdictionary] / src / mdictionary / qml / Checkbox.qml
1 import Qt 4.7
2
3 Image {
4     id: checkbox
5     property bool selected
6     signal changed
7     height: {
8         var aspectRatio = sourceSize.height / sourceSize.width
9         return checkbox.width * aspectRatio
10     }
11     width: sourceSize.width
12     smooth: true
13     states: [
14         State {
15             name: "checked";
16             when: (checkbox.selected == true);
17
18             PropertyChanges { target: checkbox; source: "qrc:/button/checkboxChecked.png" }
19         },
20         State {
21             name: "unchecked";
22             when: (checkbox.selected == false);
23
24             PropertyChanges { target: checkbox; source: "qrc:/button/checkbox.png" }
25         }
26     ]
27     MouseArea{
28         id: area
29         anchors.fill: parent
30         onClicked: {
31             checkbox.selected = !checkbox.selected
32             changed()
33         }
34     }
35 }