【发布时间】:2019-05-25 03:30:18
【问题描述】:
观察这个简单的例子:
import QtQuick 2.9
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.2
ApplicationWindow {
visible: true
width: 100
height: 100
Label {
text: "foobar"
anchors.bottom: row.top
anchors.left: label1.right
}
RowLayout {
id: row
anchors.bottom: parent.bottom
width: parent.width
Label {
id: label1
text: "hello1"
Layout.alignment: Qt.AlignLeft
}
Label {
id: label2
text: "hello2"
Layout.alignment: Qt.AlignRight
}
}
}
我在行布局中有两个项目,我想将第三个标签锚定到其中一个。这就是我得到的:
我希望 foobar 更靠右,但这不是我得到的。
此外,我为标签设置的任何边距也将被忽略。
我可以锚定到窗口或 RowLayout,它会很好地工作,但由于某种原因,我不能锚定到布局内的项目。这是什么原因,有什么合适的解决方案?
【问题讨论】: