0

I am trying to switch the orientation of the swipe on some specific item/page index of the swipeview in qml. When I change the orientation using this piece of code, index changes for no reason that I know of.

SwipeView {
    id: view
    currentIndex: 0
    anchors.fill: parent
    anchors.top: parent.top

    onCurrentIndexChanged: {
        if(view.currentIndex === 3 || view.currentIndex === 4)
            view.orientation = Qt.Vertical

        else
            view.orientation = Qt.Horizontal
    }
//home
    Item1 { }
    Item2 { }
    Item3 { } 

Is it bug or there is something that I am doing wrong ?

taimoor1990
  • 158
  • 1
  • 13
  • what/from what value does the `index` change to after changing the orientation? – folibis Jun 06 '20 at 05:43
  • whenever orientation line is called, mostly index decrements – taimoor1990 Jun 06 '20 at 06:12
  • I don't know what is `Item*` so I've just replaced it with Rectangles with different colours and added more items (since max index in your code is 2 :-) ). The code works as expected, no unexpected index changes. I advice you to provide [mcve] so we can test the code you use. – folibis Jun 06 '20 at 06:37
  • @folibis this is git repo of the code. just clone and build to see the issue in the application window of qt creator github.com/taimoortanweer1/StackPanel-QML – taimoor1990 Jun 06 '20 at 06:50
  • Can you also tell me how and where you changed the orientation of the swipe. Let say I want to switch from page 2 (horizontal) to page 3 (vertical), on which instant you will set orientation ? – taimoor1990 Jun 06 '20 at 06:52
  • Please no external links. Try to minimise your code to [mre]. From my experience 50% of problems can be solved at this stage. As for your comment, I've just took your code, so it changes when I switch to the 4-th page. – folibis Jun 06 '20 at 07:28

0 Answers0