[solved] Loader and QML files
-
Hello,
I'm having a small problem recently. I started using the
Loader
and it has worked quite well, except I need to keep the three views I've created (table view, list view, grid view) where the user left off (say the user changed the item's width in a split view, if he goes to table view and goes back to the previous one it reloads the file).How can I achieve this in qt quick? (switching between already initialized views without losing modifications)
-
@David.G
Loader
can only load a single file or component at a time. So when you change the source it is going to reload it and the changes will be lost unless you save it somewhere and load it I think you should use aStackView
instead and setdestroOnPop
tofalse
whenpush
ing. -
Hey @p3c0, thanks for replying.
I ended up pushing for that route. I was planning to use Binders (
Binding
) but thought the process would be too expensive for the cause. I ran into a little problem, since I have a sidebar on the left theStackView
animation would run over it which wasn't desirable. So for future reference all you need to do is play with thez
index. -
I know this is marked as solved, but just as an aside: to do this with a Loader, you could use a Settings object to store the properties that should be reset to restore the state of the user's view - still a Labs feature just now, but it works very nicely.