2022-05-13 13:12:05 +00:00
|
|
|
// Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
2012-01-10 11:12:51 +00:00
|
|
|
|
2022-08-31 07:59:05 +00:00
|
|
|
import QtQuick
|
2012-01-10 11:12:51 +00:00
|
|
|
|
2012-12-11 19:05:04 +00:00
|
|
|
FocusScope {
|
2012-01-10 11:12:51 +00:00
|
|
|
id: checkbox
|
|
|
|
|
|
|
|
Accessible.role: Accessible.CheckBox
|
|
|
|
|
2012-12-11 19:05:04 +00:00
|
|
|
property string text: "CheckBox"
|
2012-01-10 11:12:51 +00:00
|
|
|
property bool checked // required variable
|
|
|
|
|
2012-12-11 19:05:04 +00:00
|
|
|
width: 100
|
2012-01-10 11:12:51 +00:00
|
|
|
height: 30
|
|
|
|
|
2012-12-11 19:05:04 +00:00
|
|
|
Row {
|
|
|
|
spacing: 2
|
2013-01-21 14:53:47 +00:00
|
|
|
|
2012-12-11 19:05:04 +00:00
|
|
|
Rectangle {
|
|
|
|
width: 12
|
|
|
|
height: 12
|
|
|
|
border.width: checkbox.focus ? 2 : 1
|
|
|
|
border.color: "black"
|
2013-01-21 14:53:47 +00:00
|
|
|
|
2012-12-11 19:05:04 +00:00
|
|
|
Text {
|
|
|
|
id: checkboxText
|
|
|
|
text: checkbox.checked ? "x" : ""
|
|
|
|
anchors.centerIn: parent
|
|
|
|
}
|
|
|
|
}
|
2013-01-21 14:53:47 +00:00
|
|
|
|
2012-12-11 19:05:04 +00:00
|
|
|
Text {
|
|
|
|
text: checkbox.text
|
|
|
|
}
|
|
|
|
}
|
2013-01-21 14:53:47 +00:00
|
|
|
|
2012-12-11 19:05:04 +00:00
|
|
|
MouseArea {
|
|
|
|
anchors.fill: parent
|
|
|
|
onClicked: checkbox.checked = !checkbox.checked
|
2012-01-10 11:12:51 +00:00
|
|
|
}
|
2013-01-21 14:53:47 +00:00
|
|
|
|
2012-12-11 19:05:04 +00:00
|
|
|
Keys.onSpacePressed: checkbox.checked = !checkbox.checked
|
2012-01-10 11:12:51 +00:00
|
|
|
}
|