Another question shows how to change the color of a TabButton
depending on if it is the current index:
color: tabBar.currentIndex == 1 ? "purple" : "lightblue"
However, this requires hard-coding each button with currentIndex == 0
then currentIndex == 1
. It seems like each button or its parent layout should know what its index is. I would like to introduce CustomTabButton
control with a LOT of customization for visuals and have two options:
Is there a proper way?
index
is an attached property from TabBar.
TabBar {
id: bar
width: parent.width
TabButton {
text: (bar.currentIndex == TabBar.index) ? "AAA" : "aaa"
}
TabButton {
text: (bar.currentIndex == TabBar.index) ? "BBB" : "bbb"
}
TabButton {
text: (bar.currentIndex == TabBar.index) ? "CCC" : "ccc"
}
}