Qml Switch is not updated by model after manual set
-
In qml I have a Switch connected with a c++ bool
Q_PROPERTY(bool boolValue READ getBoolValue WRITE setBoolValue NOTIFY boolValueChanged)
If I execute the app, the Switch shows the current state of the property. I added a QTimer in c++ to set the boolValue every second. The Qml Switch toggles to. But as soon as I set the Switch in Qml, it does not toggle anymore.
Is this the expected behaviour or an error?Same behaviour with the following two Switches: Slave follows master until slave was set by the user.
Switch { id: masterSwitch } Switch { id: slave checked: masterSwitch.checked }
Regards,
Thomas -
In qml I have a Switch connected with a c++ bool
Q_PROPERTY(bool boolValue READ getBoolValue WRITE setBoolValue NOTIFY boolValueChanged)
If I execute the app, the Switch shows the current state of the property. I added a QTimer in c++ to set the boolValue every second. The Qml Switch toggles to. But as soon as I set the Switch in Qml, it does not toggle anymore.
Is this the expected behaviour or an error?Same behaviour with the following two Switches: Slave follows master until slave was set by the user.
Switch { id: masterSwitch } Switch { id: slave checked: masterSwitch.checked }
Regards,
Thomas@th.thielemann Pretty sure this is expected. You need to say something more like
Switch { id: masterSwitch onCheckedChanged: { slave.checked = checked } } Switch { id: slave }
Because you destroy your binding when the switch does its own assignment.