I have a simple list of CheckBox
es, one for each day of the week. They depend on the value of days
, an integer using a mask, 1 bit for each CheckBox
.
Assigning to days
both with the "clear all" button or the "set all" button works and they update. However, once any of the boxes have been clicked, they no longer respond to changes in the dependent property days
.
Why is this? Are they somehow becoming unbound. If so, should i be manually re-binding them, and if so why?
Here's the code,
import QtQuick 2.7
import QtQuick.Controls 1.4
import QtQuick.Layouts 1.3
ApplicationWindow
{
visible: true
width: 800
height: 400
property int days: 0
ColumnLayout
{
Repeater
{
model: ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]
CheckBox
{
text: modelData
checked: (days & (1<<index)) != false
onClicked:
{
if (checked) days |= (1<<index);
else days &= ~(1<<index);
}
}
}
Button
{
text: "clear all"
onClicked: days = 0
}
Button
{
text: "set all"
onClicked: days = 127
}
}
}
which looks like this:
To reproduce the problem, first click on "set all" and "clear all". then click on some checkboxes. Then click on "set all" and "clear all" again. You'll see that the boxes you checked are no longer affected.
thanks.