Mám GridLayout obydlený Opakovač (TableView nesedí mé potřeby), uvnitř Flickable, takže můžu posouvat obsah.
Chci, aby moje GridLayout mít záhlaví, které mohu snadno přidáním Text
s před mým Opakovač, jako je tento:
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)
}
}
}
}
}
}
Nicméně rád bych, aby moje hlavička bude "sticky" / "zmrazené", tj. zůstávají viditelné při posouvání Flickable. Bych mohl vytvořit svou hlavičku mimo Flickable, nicméně GridLayout nedává mi poslední řadě velikostí, takže nemohu pozici záhlaví moje texty.