当我在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
}
答案 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
}
}
一起使用:
currentIndex
因此,更改TabBar
的{{1}}属性会自动执行SwipeView
过渡到相应的项目。
因为我的问题并不完全清楚,所以我不知道这是否是您想要实现的目标。