In qml i have a page main.qml, if i click on rectangle in that page it opens a component from second.qml file and a listview appears. The listview is very long and can be scrolled down. To go out to the main.qml (previous page) from second.qml it is also done by creating a back button. So far everything is ok and it works and is done by using loader and then changing the loader source.
The problem starts when i revisit the second.qml after clicking again on the rectangle in main.qml. This time it shows the listview left at the last time. What i want is to reload the second.qml as it loaded it first time. I have came across clear componentcache etc. However, it is not working for me.
A simple example on how to clear the cache memory of loader to reload it like i was loaded first time in qml would be helpful.
in main.qml
MouseArea {
anchors.fill: parent
onClicked: {
pp.close()
//clearComponentCache(loader)
loader.setSource("second.qml",
{ "x":0,
"y":30});
//loader.reload()
}
}
Component.onDestruction:{console.log("second destroyed")}
to your component to see if it is destructed. – Soheil Armin