In QML, I'm using TabButton and I need its x value for some customization but when I'm using its x value it's not working correctly now consider the below QML code
import QtQuick 2.15
import QtQuick.Window 2.15
import QtQuick.Controls 2.14
import QtQuick.Layouts 1.14
Window {
height: 768
width: 432
visible: true
title: qsTr("Hello World")
TabBar {
id: bar
width: parent.width
LayoutMirroring.enabled: false
TabButton {
text: qsTr("Home")
onClicked: console.log("Home: " + x)
}
TabButton {
text: qsTr("Discover")
onClicked: console.log("Discover: " + x)
}
TabButton {
id:activityButton
text: qsTr("Activity")
onClicked: console.log("Activity: " + x)
}
}
StackLayout {
width: parent.width
currentIndex: bar.currentIndex
Item {
id: homeTab
}
Item {
id: discoverTab
}
Item {
id: activityTab
}
}
}
When I click on TabButtons output is like below
qml: Discover: -143.66666666666666
qml: Activity: 0.6666666666666856
qml: Home: -288
Can anyone explain to me why this value is not correct and it's negative?
And why the correct value is (288 + x)?




