Reputation: 312
I have a TabView
with 3 Tab
s and I want to change the focus/select the third Tab
when a button is pressed. I've tried forceActiveFocus
, but it does not work.
//.qml
TabView {
Tab {
id: redTab
title: "Red"
Rectangle { color: "red" }
}
Tab {
id: blueTab
title: "Blue"
Rectangle { color: "blue" }
}
Tab {
id: greenTab
title: "Green"
Rectangle { color: "green" }
}
}
ToolButton {
inconSource: "lock.png"
onClicked: {
greenTab.forceActiveFocus() // does not work?
}
}
Upvotes: 0
Views: 857
Reputation: 5836
Set the currentIndex
:
TabView {
id: tabView
//...
}
//...
tabView.currentIndex = 2
Upvotes: 3