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
?