Qt 5.4/Qml: Prevent binding loop

前端 未结 5 1323
孤街浪徒
孤街浪徒 2021-02-19 04:04

I have a global singleton \"Settings\" which holds application settings. When I try to run the following code I get a QML CheckBox: Binding loop detected for property \"ch

5条回答
  •  感动是毒
    2021-02-19 04:48

    Sometimes it is useful to separate input and output values in control. In this case control always displays real value and it can also show a delay to the user.

    CheckBox {
        checked: Settings.someSetting
        onClicked: Settings.someSetting = !checked
    }
    

提交回复
热议问题