Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QML Binding only functions ones



  • Hello!

    I have two components: a Slider with property value and a Prompt with property promptValue. The Slider and the Prompt should both show the same value. With the buttons of the Prompt one can increment or decrement the value. In another Qml file I instantiate the slider and the prompt and use Bindings to make a bidirectional connection to the backend:

    Slider Binding:

    @MySlider {
    id: slider
    maximum: 450
    minimum: 220
    value: backendObject.backendVlaue

                                        Binding {
                                            target: backendObject
                                            property: "backendVlaue"
                                            value: slider.value
    

    }@

    Prompt Binding:

    @Prompt {
    id: prompt
    max: 450
    min: 220
    promptValue: backendObject.backendValue

                                        Binding {
                                            target: backendObject
                                            property: "backendValue"
                                            value: prompt.promptValue
                                        }
    

    }@

    The thing is it only functions ones. Either i move the handle of the slider, then the value is updated and shown correctly both in slider and in the prompt. Or I push the buttons, then the handle and the prompt values are being updated and shown correctly. If I first move the slider, then push the buttons and then move the slider again, the values will not update. Or vice versa.
    Can anyone comprehend the problem? As I understand the value should be updated automatically through Bindings and my two components use the same value, so why do they differ when I move the slider second time after pushing the buttons of the prompt?

    thanx and best regards


Log in to reply