0
我想表明连续4个辨认的按钮:项目有不正确的几何
import QtQuick 2.4
import QtQuick.Window 2.2
import QtQuick.Controls 1.2
import QtQuick.Layouts 1.1
Window {
id: main
visible: true
width: 600; height: 350
ColumnLayout {
id: mainColumn
anchors.fill: parent // takes all available width
RowLayout {
Repeater {
id: rep
model: ["first", "second", "third", "fourth"]
Component.onCompleted: console.log(count)
Button {
text: modelData
checkable: true
Layout.preferredWidth: mainColumn.width/rep.count // (!)
}
}
}
// more elements
}
}
然后第四个按钮被切断(好像额外的间距被引入或按钮太宽)。
如果我用而不是RowLayout
和width
而不是Layout.preferredWidth
,项目显示正确。
他们为什么不与RowLayout
?