我想将 RowLayout 内的最后一项向右对齐,但即使 RowLayout 的宽度大于所有子项的宽度,该项目仍紧跟在其他项目之后。如果我使用anchors.right:parent.right
它运行良好,但我收到警告。
ToolBar {
height: globals.toolBar.height
width:parent.width
background: Rectangle {
anchors.fill: parent
color:"white"
}
RowLayout {
id: row
anchors.fill: parent
Button{
Layout.alignment: Qt.AlignLeft
contentItem: Image {
source: "images/iconmenu.png"
}
}
Button {
Layout.alignment: Qt.AlignLeft
contentItem: Image {
source: "images/iconget.png"
}
ToolTip.text: qsTr("Get Data from Panel")
ToolTip.visible: hovered
}
Button {
id:buttonAbout
Layout.alignment:Qt.AlignRight
font.family: fontAwesomeSolid.font
width:15
height: 15
text: "\uf129"
ToolTip.text:qsTr("about")
ToolTip.visible: hovered
contentItem: Text {
anchors.fill:buttonAbout
anchors.right:buttonAbout.right
anchors.topMargin: 3
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCente
text: buttonAbout.text
}
background:
Rectangle{
width:20
height: 20
anchors.right: parent.right
anchors.topMargin: 20
radius:10
border.width: 1
border.color:"gray"
}
onClicked: popup.open()
}
Item {
Layout.fillWidth: true
}
}
}
我想要的是这个
似乎 Row 和 RowLayout 不允许这样存在空白空间。但它可以使用执行 fillwidth:true 的组件来解决
Item{
Layout.fillWidth: true
height: buttonAbout.implicitHeight
Button{
id:buttonAbout
}
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句