我在TreeView上为每个项目都有一个CheckBox,所以当我选中/取消选中父项时,如何选中/取消选中它的所有子项? 这是我的代码:
TreeView {
id: treeview
width: parent.width
height: parent.height
headerVisible: false
model: TreeViewController
TableViewColumn {
title: "Name"
role: "name_role"
}
TableViewColumn {
title: "Description"
role: "description_role"
}
itemDelegate: listTreeDelegate
Component {
id: listTreeDelegate
Item {
id: listTreeDelegateItem
CheckBox {
id: checkbox
checked:false
visible: styleData.value === undefined ? false : true
MouseArea {
anchors.fill: parent
onClicked: {
if (parent.checked === true) {
parent.checked = false
} else {
parent.checked = true
}
}
}
}
}
}
}