How to inspect binding on property?
-
I am using RadioButton items and I am confused as to why my bindings to the checked property are not being broken when I click the buttons. This test program lets me test this out but check if the bindings are still working. If I click any of these RadioButtons I would expect the binding to break. But when enabling the timer (which activates a cycle to test the bindings) it acts as if the binding is working. Very confused.
import QtQuick 2.15 import QtQuick.Window 2.15 import QtQuick.Controls 2.15 Window { width: 640 height: 480 visible: true title: qsTr("Property Binding Test") Rectangle { anchors.fill: column1 color: "lightblue" } Column { id: column1 property int radioValue: 0 RadioButton { id: rad1 checked: column1.radioValue === 0 onClicked: column1.radioValue = 0 } RadioButton { id: rad2 checked: column1.radioValue === 1 onClicked: column1.radioValue = 1 } RadioButton { id: rad3 checked: column1.radioValue === 2 onClicked: column1.radioValue = 2 } RadioButton { id: rad4 checked: column1.radioValue === 3 onClicked: column1.radioValue = 3 } } Timer { running: checkbox.checked interval: 500 repeat: true onTriggered: { let tmp = column1.radioValue tmp += 1 if(tmp >= 4){ tmp = 0 } column1.radioValue = tmp for(let cnt=0; cnt < column1.children.length; ++cnt){ console.log(column1.children[cnt].checked) } } } CheckBox { id: checkbox anchors.top: column1.bottom text: "Run" } }
-
I am using RadioButton items and I am confused as to why my bindings to the checked property are not being broken when I click the buttons. This test program lets me test this out but check if the bindings are still working. If I click any of these RadioButtons I would expect the binding to break. But when enabling the timer (which activates a cycle to test the bindings) it acts as if the binding is working. Very confused.
import QtQuick 2.15 import QtQuick.Window 2.15 import QtQuick.Controls 2.15 Window { width: 640 height: 480 visible: true title: qsTr("Property Binding Test") Rectangle { anchors.fill: column1 color: "lightblue" } Column { id: column1 property int radioValue: 0 RadioButton { id: rad1 checked: column1.radioValue === 0 onClicked: column1.radioValue = 0 } RadioButton { id: rad2 checked: column1.radioValue === 1 onClicked: column1.radioValue = 1 } RadioButton { id: rad3 checked: column1.radioValue === 2 onClicked: column1.radioValue = 2 } RadioButton { id: rad4 checked: column1.radioValue === 3 onClicked: column1.radioValue = 3 } } Timer { running: checkbox.checked interval: 500 repeat: true onTriggered: { let tmp = column1.radioValue tmp += 1 if(tmp >= 4){ tmp = 0 } column1.radioValue = tmp for(let cnt=0; cnt < column1.children.length; ++cnt){ console.log(column1.children[cnt].checked) } } } CheckBox { id: checkbox anchors.top: column1.bottom text: "Run" } }