在 TabView Qt QML 中以编程方式更改 Tab



如何在Qt Quick QML的TabView中更改选项卡 这是我的代码

TabView {
id: main_tab
width: 799
height: 560
tabsVisible: false
Tab {
id: home_tab
source: "Home.qml"
title: "Home"
}
Tab {
id: led_tab
source: "Led.qml"
title: "Led"
}
}

我尝试使用main_tab.getTab(1).active = true设置新选项卡,但没有成功。

您必须更改TabViewcurrentIndex属性:

main_tab.currentIndex = 0 // Will show home_tab
main_tab.currentIndex = 1 // Will show led_tab

最新更新