如何在gridLayout中有兩列,其中第一列占據20%的空間,第二列自動填充其余空間,就像css中發生的那樣?我試試這個,但現在作業:
GridLayout{
id:root
anchor.fill:parent
columns:5
rows:1
Column{
id: col1
Layout.column:0
Layout.columnSpan:1
}
Column{
id: col2
Layout.column:1
Layout.columnSpan:4
}
}
最后,請給我看一篇在布局方面受過良好訓練的文章。
uj5u.com熱心網友回復:
您是在假設列相等但它們不相等的情況下構建它的。您必須明確設定列大小。
GridLayout {
anchors.fill: parent
columns: 2
columnSpacing: 0
Rectangle {
Layout.preferredWidth: parent.width * 0.2;
Layout.preferredHeight: 50
color: "orange"
}
Rectangle {
Layout.fillWidth: true
Layout.preferredHeight: 50
color: "green"
}
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/407448.html
標籤:
