QML how to save variable value while changing to anothe qml.
-
I want to save the value of a variable when I change the QML and then come back to the same qml again. How can I do that? The valuıe gets zeroed after when I open the corresponding QML.
I open new qml from my main.qml by using loader.RightButtons { MultiPointTouchArea { onPressed: { pageLoader.source="CTISpage.qml" } } }
And here is my loader
Loader { id:pageLoader Connections { target:pageLoader.item onBackButtonPressed: { pageLoader.source="" } } }
So when I press the button I set the loader new source and open the page, and from the new page when I press the back button, I set source of loader to an empty string and make it return to my main.qml.
Here is the problem: In the new qml I use a boolean variable and I want to save it's value between going back to main.qml and returning to this qml. But it gets zeroed all the time in this process. Here is what my new qml looks like:
Item { id: CTISPage.qml . . . signal backButtonPressed() property var isABSOffRoad:false:false . . . LeftButtons { MultiPointTouchArea { onPressed: { isABSOffRoad=!isABSOffRoad if(ABSOffRoad) { //Do sth if it is true } } } } }
When I press the button and set the boolean isABSOffRoad variable to true, it gets false when I go back to main and come back to this qml again. I also tried to declared the boolean variable in main and then reach that variable from this qml. However, the result is same. I also tried to open a new variables.qml file and declared all that variables in that qml and reach them from there. But that did not work either. How can I find a way around for this?