我想连续显示四个可检查按钮:
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
}
}
然后,第四个按钮被切断(好像引入了额外的间距或按钮太宽)。
如果我使用
Row
而不是
RowLayout
和
width
而不是
Layout.preferredWidth
,项目将正确显示。
为什么他们没有
行列式
?