我有一个GridLayout人口由一个中继器(提供一个不适合我的要求),内Flickable所以我可以滚动的内容。
我想我GridLayout有一个头,我可以很容易地通过增加 Text
s前我中继器像这样:
import QtQuick 2.0
import QtQuick.Layouts 1.12
ColumnLayout {
width: 200
height: 200
Flickable {
Layout.fillWidth: true
Layout.preferredHeight: 200
contentWidth: width
contentHeight: grid.height
clip: true
GridLayout {
id: grid
columns: 3
columnSpacing: 10
function reparentChildren(source, target) {
while (source.children.length) {
source.children[0].parent = target;
}
}
// Header
Text {
text: "Header 0"
}
Text {
text: "Header 1"
}
Text {
text: "Header 2"
}
// Data
Repeater {
model: 50
Item {
Component.onCompleted: grid.reparentChildren(this, grid)
Text {
text: "Column 0, %1".arg(modelData)
}
Text {
text: "Column 1, %1".arg(modelData)
}
Text {
text: "Column 2, %1".arg(modelData)
}
}
}
}
}
}
但是我想我的标题是"粘"/"冻结",即仍然可见的时候滚动Flickable. 我可以创造我的头外Flickable,但GridLayout不能给我的最后一行的大小,因此我不能置我的头的案文。