Using loader how to save the components and not destroy them
-
Currently, I am navigating from one page to another in QML using Loader.
In this application example let us assume we have two qml files main and second .qml .One can navigate from main.qml to second.qml and vice versa by simply changing Loader.source. Current problem with this approach is that as soon as loader source is changed the component is destroyed and on revisiting the page the component is created again.
I am looking for some way in which i can save this component in that state. Basically android back button does that for android apps.
In this example i have two buttons in main.qml i.e. back and create. If i click on create button it will create the new component of second.qml and app will be directed to it. If I click on back button from main.qml then if second.qml has been visited before it will open that instance of second.qml which is somehow saved when first time second.qml was redirected to main.qml.
I want to have both the options i.e. create a new component and revisiting the component in previous state via loader.
Thank You