-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathCheckbox.qml
49 lines (38 loc) · 1.02 KB
/
Checkbox.qml
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
38
39
40
41
42
43
44
45
46
47
48
49
import QtQuick 2.0
Rectangle {
id: checkbox
Accessible.role: Accessible.CheckBox
property string text: "CheckBox"
property bool checked // required variable
// width, height for checkbox's square rect
property int boxLen: 20
width: 100
height: 40
Row {
spacing: 2
Rectangle {
width: boxLen
height: boxLen
border.width: checkbox.focus ? 2 : 1
border.color: "black"
radius: 4
Image {
id: checkboxText
source: "qrc:/imgs/images/tick.png"
anchors.centerIn: parent
width: parent.width - 4
height: parent.height - 4
visible: checked
}
}
Text {
text: checkbox.text
y: 4
}
}
MouseArea {
anchors.fill: parent
onClicked: checkbox.checked = !checkbox.checked
}
Keys.onSpacePressed: checkbox.checked = !checkbox.checked
}//checkbox