2

Is it possible to remove the animation from swipeviews? The one where you see the transition from the previous and the next page. I have many pages and I have a menu that selects the active item like:

mainContent.setCurrentIndex(0)

where mainContent is the swipeview.

    // The content changes based on what is clicked on in the menu
    SwipeView{
        width: mainWindow.width - mainMenuId.width -anchors.leftMargin
        id:mainContent
        anchors.leftMargin:  20
        anchors.topMargin: 20
        clip:true
        Component.onCompleted: contentItem.interactive = false
        currentIndex: 0

        Item{PageMain{}}                 
        Item{PageTests{}}             
        Item{PageData{}}                                
        Item{PageSavedFiles{}}                          
        Item{PageProbe{}}                               

}
eyllanesc
  • 235,170
  • 19
  • 170
  • 241
Sven van den Boogaart
  • 11,833
  • 21
  • 86
  • 169

1 Answers1

3

Either you can override the contentItem and disable ListView's animation, or, if you don't really need the swipe part of SwipeView, use e.g. StackLayout instead:

TabBar {
    id: bar
    width: parent.width
    TabButton {
        text: qsTr("Home")
    }
    TabButton {
        text: qsTr("Discover")
    }
    TabButton {
        text: qsTr("Activity")
    }
}

StackLayout {
    width: parent.width
    currentIndex: bar.currentIndex
    Item {
        id: homeTab
    }
    Item {
        id: discoverTab
    }
    Item {
        id: activityTab
    }
}

That code is using TabBar, but I think you get the idea. :)

Mitch
  • 23,716
  • 9
  • 83
  • 122
  • Thanks I ended up using the StackLayout, I can set the currnet index with: currentIndex=newIndex instead of setCurrentIndex(newIndex). Works as I wanted now. – Sven van den Boogaart Jul 17 '19 at 14:17