QML Swipeview没有动画

时间:2019-07-16 11:43:33

标签: qt qml swipeview

是否可以从swipeviews中删除动画?您可以在其中看到上一页和下一页的过渡。我有很多页面,并且有一个菜单可以选择活动项目,例如:

mainContent.setCurrentIndex(0)

其中mainContent是滑动视图。

    // 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{}}                               

}

1 个答案:

答案 0 :(得分:1)

您可以覆盖contentItemdisable ListView的动画,或者,如果您确实不需要SwipeView的滑动部分,请使用例如改为StackLayout

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
    }
}

该代码正在使用TabBar,但我认为您明白了。 :)