I have a ListView filled with checkboxes, I want to change the checkbox status from a button click this is my code.
import QtQuick
import QtQuick.Controls 2.15
Window {
width: 640
height: 480
visible: true
title: qsTr("Hello World")
ListView {
id: mylist
width: parent.width
height: 300
anchors {
top: parent.top
left: parent.left
right: parent.right
bottom: change_state.top
bottomMargin: 20
}
model: ListModel {
id: mymodel
ListElement {
mystatus : false
}
ListElement {
mystatus : false
}
ListElement {
mystatus : false
}
}
delegate: Rectangle {
height: 50
width: parent.width
CheckBox {
id: cb
checked: mystatus
anchors.fill: parent
text: "State"
}
}
}
Button {
id: change_state
anchors {
bottom: parent.bottom
}
text: "Change status"
onClicked: {
mymodel.setProperty(1, "mystatus", true)
console.log("PRESSED")
}
}
}
The problem is when I press the button after running the app it changes the status and checks the box, but if I remove the check manually then press the button again it has 0 effects, never been able to check it again.
QT 6.3 Windows 10 same issue for Android, IOS, and Desktop.
Tested with QT 5.15.2 and the same issue.