我有一个QML TextItem,其中文本是动态设置的。宽度我无法确定,因为文本可以有任意数量的字符。
我需要在旁边放置另一个文本项。
因此,当我们无法确定文本的宽度时,如何定位到文本项的右侧,因为文本可以随时增长。不允许Wrap或Elide
例如:
Text
{
id: distance
width: //dont know what to provide
font.bold: true
verticalAlignment:Text.AlignBottom
horizontalAlignment:Text.AlignLeft
maximumLineCount: 1
onTextChanged:
{
console.log("$$$$$___Text is been changed:" + txt_distance.paintedWidth +" "+ paintedHeight)
}
anchors
{
bottom: parent.bottom
bottomMargin: 2
left: parent.left
leftMargin: 20
right: //Dont know what to give
}
和相邻项
Text
{
id: address
font.bold: true
verticalAlignment:Text.AlignBottom
horizontalAlignment:Text.AlignLeft
maximumLineCount: 1
anchors
{
bottom: parent.bottom
bottomMargin: 2
left: distance.right <-- Please help
right: parent.right
rightMargin: 20
}
}