我目前能夠集中text2在text1. 當我嘗試將 Image 元素與text2. 實作這一目標的最佳方法是什么?
Text {
id: text1
anchors.fill: parent
text: qsTr("No tests results")
wrapMode: Text.WordWrap
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
Image {
anchors.right: text2.left
source: "icons"
key: { 'col': 1, 'row': 0 }
MouseArea {
anchors.fill: parent
onClicked: {
console.log("Clicked")
}
}
}
Text {
id: text2
anchors.fill: parent
anchors.top: text1.bottom
anchors.topMargin: 60
text: qsTr("Retry")
wrapMode: Text.WordWrap
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
uj5u.com熱心網友回復:
有點難以理解您所描述的問題究竟是什么,但您似乎正在與影像專案的定位作斗爭。如果是這種情況,您需要設定影像的垂直錨點,例如:
Image {
anchors.right: text2.left
anchors.verticalCenter: text2.verticalCenter
source: "icons"
key: { 'col': 1, 'row': 0 }
MouseArea {
anchors.fill: parent
onClicked: {
console.log("Clicked")
}
}
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/388248.html
