这是 Qt Design Studio,不是 Qt Quick Designer,但可能是一样的。
我做了一个组件,
PaneWithTitle.qml
Column {
id: column
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
spacing: Style.paneTitleOffset
property string title
property alias inside: inner_space.sourceComponent
DefaultText {
text: qsTr(title)
}
Pane {
id: pane
background: Rectangle {
color: "#283547"
radius: Style.rectangleCornerRadius
}
Loader {
id: inner_space
}
}
}
我正在像这样使用它:
PaneWithTitle {
title: "Recovery"
inside: ColumnLayout {
id: rows
TextFieldWithTitle {
id: seed_input
title: qsTr("Seed")
}
TextFieldWithTitle {
id: password_input
title: qsTr("Password")
}
RowLayout {
id: columns
Button {
id: back_button
text: qsTr("Back")
}
Button {
id: confirm_button
text: qsTr("Confirm")
}
}
}
}
当我运行它时,它在实时预览中看起来不错。但在编辑器中,窗格背景的大小为 0。
有没有一个优雅的解决方案?