Best way to manage multiple random screens in a single window
-
Hello!
I was wondering about the best way to manage multiple screens that are interconnected very vaguely between each other.
For example, there's main.qml, item1.qml, item2.qml, item3.qml and basically from any screen I should be able to reach any other screen.
Ex. main -> item1 -> item3 -> main -> item2 -> item1 -> mainSo far I have been using Stackview but it's obviously not for my use case. I am thinking about Loader - but I don't understand - does it always keep loaded previous screens? I mean how can I guarantee consistent load times and animations? Can I just load all screens at once in Loader and just set the current Loader.source so it won't reload? (I'm ok with longer initialization but not okay with inconsistent loading).
Maybe something else than Loader should be used? Simple Component show/hide?
-
@therealmatiss said in Best way to manage multiple random screens in a single window:
So far I have been using Stackview but it's obviously not for my use case.
Why not?
-
Because I want to access stackview items that are not in order. For example, go to the middle of the stack.
-
I use a StackView with a depth of 1. I use a ListView to display buttons that select which I want displayed in the stack. When the currentIndex in the ListView changes it calls the replace function on the StactView: replace(currentItem, panemodel[ind].comp). panemodel is a list of objects with name I use for listview button objects and the component for the current view in the StackView. When replace is called I believe the old item gets destroyed. So I have only one item loaded at any time. A Loader would probably work just fine too.
Edit: StackView has some niceties. Like having an initialItem that can be set. I set this to item 0 in my list of objects.
Edit 2: In thinking about this. I probably should have used a Loader.