import QtQuick 2.12
import QtQuick.Window 2.12
import QtQuick.Controls 2.12
Window {
visible: true
width: 640
height: 480
title: qsTr("My QML")
color: "white"
CheckBox {
tristate: true
// checkState: allChildrenChecked ? Qt.Checked :
// anyChildChecked ? Qt.PartiallyChecked : Qt.Unchecked
nextCheckState: function() {
if (checkState === Qt.Checked)
return Qt.Unchecked
else if (checkState === Qt.Unchecked)
return Qt.PartiallyChecked
else
return Qt.Checked
}
}
// Column {
// ButtonGroup {
// id: childGroup
// exclusive: false
// checkState: parentBox.checkState
// }
// CheckBox {
// id: parentBox
// text: qsTr("Parent")
// checkState: childGroup.checkState
// }
// CheckBox {
// checked: true
// text: qsTr("Child 1")
// leftPadding: indicator.width
// ButtonGroup.group: childGroup
// }
// CheckBox {
// text: qsTr("Child 2")
// leftPadding: indicator.width
// ButtonGroup.group: childGroup
// }
// CheckBox {
// text: qsTr("Child 3")
// leftPadding: indicator.width
// ButtonGroup.group: childGroup
// }
// }
// ButtonGroup {
// id: childGroup
// exclusive: false
buttons: col.children
// }
// Column{
// id: col
// CheckBox {
// checked: true
tristate: true
autoExclusive: true
// text: qsTr("First")
// ButtonGroup.group: childGroup
onCheckStateChanged: {
console.log(checkState)
}
// }
// CheckBox {
// checkable: true
autoExclusive: true
// text: qsTr("Second")
// ButtonGroup.group: childGroup
// }
// CheckBox {
autoExclusive: true
// checkable: true
// text: qsTr("Third")
// ButtonGroup.group: childGroup
// }
// }
}
Qt_Note12_QML_CheckBox
于 2024-03-21 15:34:58 首次发布