如何在tabview中的更改选项卡中实现转换?

时间:2017-12-27 01:53:38

标签: qt qml

当我在QML中的TabView中的选项卡之间导航时,我试图找到实现转换的任何方法,但我找不到,有什么方法可以做到吗?

我的代码是:

TabView{
    id : tbView
    height: parent.height
    width: parent.width


    Tab{
        HomePage{
            id: home
            height: tbView.height
            width: tbView.width
            onBtnConfigClicked: btnPlay()
        }
    }
    Tab{
        Rectangle{
            anchors.fill: parent
            color: "blue"
        }
    }
}



function btnPlay()
{
    tbView.currentIndex = 1
}
HomePage元素有一个信号btnConfigClick,然后我将它附加到函数btnPlay,它的函数将currentIndex属性改为1,第一个tab为0,我想在更改currentIndex时进行幻灯片转换。

1 个答案:

答案 0 :(得分:0)

好吧,您可以将SwipeView组件与TabBar { id: bar width: parent.width TabButton { text: qsTr("Home") } TabButton { text: qsTr("Discover") } TabButton { text: qsTr("Activity") } } SwipeView { width: parent.width currentIndex: bar.currentIndex Item { id: homeTab } Item { id: discoverTab } Item { id: activityTab } } 一起使用:

来自documentation

currentIndex

因此,更改TabBar的{​​{1}}属性会自动执行SwipeView过渡到相应的项目。

因为我的问题并不完全清楚,所以我不知道这是否是您想要实现的目标。