I currently have an image which becomes visible or not depending on some steps of a process. The qml code for that image is the following :
Image
{
id : cameraDisplay
visible : mainViewModel.getCurrentSegmentIsCameraDisplayed
anchors.centerIn : parent
source: "Images/Todo.png"
}
I also have a button, which the user can press to display that image or not :
Button
{
Layout.fillWidth: true
Layout.fillHeight: true
buttonText : "CAMERA"
onClicked: {cameraDisplay.visible = !cameraDisplay.visible;}
}
In the c++, the binding looks like this :
Q_PROPERTY(bool getCurrentSegmentIsCameraDisplayed
READ getCurrentSegmentIsCameraDisplayed
NOTIFY segmentChanged)
the idea is that every time the current step of the process changes in my program, a notification is sent. That notification is then sent to the QML, which then gets the backend value to know if the camera should display or not that image.
I also have a button, which allows the user to toggle on or off the visibility of that image. The problem is that once that button is clicked, I lose the Q_PROPERTY binding, which means that once I go to the next segment, the notifications sent to the qml won't change the visibility of the image.
So basically, what I would want would be the following situation :
- The segment changes, a notification is sent to the qml, and the visiblity of the image is updated automatically.
- The user presses the button, which toggles the visibility of that image.
- The segment changes again, a notification is sent to the qml, and the visibility of that image is again updated according to the backend.
Currently, step 3 doesn't work. What should I change to make it work?
thanks