Qt 5.4/Qml: Prevent binding loop

前端 未结 5 1354
孤街浪徒
孤街浪徒 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:34

    You can also make two-way binding to resolve this issue:

    CheckBox {
        id: checkBox
    
        Binding { target: checkBox; property: "checked"; value: Settings.someSetting }
        Binding { target: Settings; property: "someSetting"; value: checkBox.checked }
    }
    

提交回复
热议问题