我发展,我已经做了两个按钮和两个labeltextfield的UI。问题是,对准我不能在做的RowLayout内项目。并且按钮也没有锚定到文本框的底部。我已经设置了anchor.bottom到textfield.bottom。
我设置了Layout.Alignment = Qt.AlignBottom但是,这不是工作
GroupBox{
id: gb
RowLayout{
id:rl
Button{
id: btn1
text:"Btn1"
Layout.preferredHeight: 30
Layout.preferredWidth: 150
anchors.bottom: tlfield.bottom
}
Button{
id: btn2
text:"Btn2"
Layout.preferredHeight: 30
Layout.preferredWidth: 150
anchors.bottom: tlfield.bottom
}
LabeledTextFieldVertical
{
id: tlfield
fieldLabel.text: "text"
fieldText.text: check
fieldText.maximumLength: 15
Layout.preferredWidth: 130
fieldText.height:30
Layout.alignment: Qt.AlignBottom
shouldFillWidth: false
}
}
}
布局和锚固件是两种不同的机制,请参阅进一步阅读Qt Quick Layouts和Positioning with Anchors。