use*_*140 5 qt qml qt-quick qtquickcontrols
我Row习惯于在Rectangle自定义工具栏实现上布局一些按钮。问题是无论我做什么,组件始终从左对齐。我希望它们与行的中心对齐并向外流向边缘。该代码如下所示:
Rectangle {
id: toolbar
color: "green"
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: parent.bottom
height: 100
Row
{
anchors.fill: parent
anchors.horizontalCenter: parent.horizontalCenter
spacing: 60
ToolButton {
height: parent.height
Image {
anchors.verticalCenter: parent.verticalCenter
source: "../images/image.png"
}
}
ToolButton {
height: parent.height
Image {
anchors.verticalCenter: parent.verticalCenter
source: "../images/image.png"
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
我的按钮总是从行的左侧开始布置。相反,我希望它们相对于工具栏的中心进行布局。我认为指定该行anchors.horizontalCenter: parent.horizontalCenter应该可以实现,但是无论我如何尝试,组件都应从左侧边界布局。
| 归档时间: |
|
| 查看次数: |
4154 次 |
| 最近记录: |