Hi Guyz
I am struck with this simple logic in assigning selected child checkbox values to header checkbox values.This requiremnet is as simple as we see in our daily life i.e., When i select/unselect Header Checkbox all child checkboxes has to be selected/unselected. I could do the above requiremnet. Going further ,when i deselect any of the child checkbox ,header checkbox has to be deselected.I could not achieve the same.Can you guys help me in achieving this as i am struggling for few days. Here i add my source code which i am able to select/deselect child checkbox wen i change header checkbox accordingly.
Rectangle{
id: header
width: 620
height: 70
y: 150
color: "#E8E8E8"
anchors{left: parent.left;leftMargin: 110;top:separator.bottom}
CheckBox {
id: headerCombo
text: qsTr("Select All")
checked: false
anchors{left: parent.left;leftMargin: 38;top:parent.top;topMargin: 20}
onCheckedChanged: {
for(var i=0;i<checkBoxModel.count;i++)
{
checkBoxModel.set(i,{"selected": headerCombo.checked})
}
}
}
}
ListModel {
id: checkBoxModel
ListElement { selected: false; }
ListElement { selected: false; }
ListElement { selected: false; }
ListElement { selected: false; }
ListElement { selected: false; }
ListElement { selected: false; }
}
ListView{
id: listt
model: checkBoxModel
clip:true
width: 620
anchors{left: parent.left;leftMargin: 110;top: header.bottom;topMargin: 10;bottom: bottomBar.top}
delegate: listDelegate
}
Component {
id: listDelegate
Item {
id: name
width: 620
height: 70
CheckBox {
id: childCombo
text: qsTr("Select All")
checked: selected
anchors{left: parent.left;leftMargin: 38;top:parent.top;topMargin: 20}
}
}
}
Rectangle{
id: header
width: 620
height: 70
y: 150
color: "#E8E8E8"
anchors{left: parent.left;leftMargin: 110;top:separator.bottom}
CheckBox {
id: headerCombo
text: qsTr("Select All")
checked: false
anchors{left: parent.left;leftMargin: 38;top:parent.top;topMargin: 20}
onCheckedChanged: {
for(var i=0;i<checkBoxModel.count;i++)
{
checkBoxModel.set(i,{"selected": headerCombo.checked})
}
}
}
}
ListModel {
id: checkBoxModel
ListElement { selected: false; }
ListElement { selected: false; }
ListElement { selected: false; }
ListElement { selected: false; }
ListElement { selected: false; }
ListElement { selected: false; }
}
ListView{
id: listt
model: checkBoxModel
clip:true
width: 620
anchors{left: parent.left;leftMargin: 110;top: header.bottom;topMargin: 10;bottom: bottomBar.top}
delegate: listDelegate
}
Component {
id: listDelegate
Item {
id: name
width: 620
height: 70
CheckBox {
id: childCombo
text: qsTr("Select All")
checked: selected
anchors{left: parent.left;leftMargin: 38;top:parent.top;topMargin: 20}
}
}
}
To copy to clipboard, switch view to plain text mode
Regards
Bala Beemaneni
Bookmarks