State Transition Problem
-
I have 2 states, page1 and page2, i want to make a sliding transition so page1 goes ofscreen and a the same time page2 comes in. I use a Loader Component and i don't now where to start. Here is my main code.
ApplicationWindow { title: qsTr("Test3") width: Screen.desktopAvailableWidth height: Screen.desktopAvailableHeight visible: true Loader { id: pageLoader anchors.fill: parent source: "PageMain.qml" states: [ State { name: "MAIN" PropertyChanges { target: pageLoader; source: "PageMain.qml"} }, State { name: "FAVORITES" PropertyChanges { target: pageLoader; source: "PageFavorites.qml"} } ] transitions: [ Transition { to: "*" // Transition } ] } }
-
Hi @Maxim-DC and Welcome,
IMO, instead of using aLoader
and loading QML's here for sliding purpose would be a bad idea. You may need to maintain a lot ofStates
andTransitions
.
Instead I would suggest you to use StackView. To load and unload you just need to push and pop the QML files into it. And yes it provides transitions too. By default it will slide.
If you don't want to useStackView
then you can use aListView
with its delegate as aLoader
which will load your QML files. Just changeListView
's orientation toQt.Horizontal
. By incrementing and decrementing thecurrentIndex
the items in theListView
will slide accordingly. Also just make sure the delegates size is filled to the screen size to get a feel similar to what you are trying.