【发布时间】:2015-06-02 08:15:06
【问题描述】:
我有一个 QML ColumnLayout 有几个孩子,我想限制它的宽度,像这样:
ColumnLayout {
width: 360
height: 480
ColumnLayout {
id: inner
Layout.maximumWidth: 200
Layout.fillHeight: true
Text {
text: "Welcome"
font.pixelSize: 18
}
Text {
text: "Long explanation that should wrap, but ends up overflowing layout"
wrapMode: Text.WrapAnywhere
}
}
Rectangle {
anchors.fill: inner
z: -1
border.color: "orange"
}
}
我得到了下图所示的结果。
橙色框显示内部布局项的尺寸,可以。但是,布局的子文本没有换行。
我只能通过添加来解决这个问题
Layout.maximumWidth: parent.width
到我的“文本”项目,但这是非常尴尬的方法。我做错了什么,或者这是一个 Qt 错误,还是出于某种原因它是一种设计方法?我正在使用 Qt 5.4.1。
【问题讨论】: