Я хочу получить фиксированные столбцы в GridView, такие как Gird.columns.
Является ли это возможным?
Я попробовал verticalLayoutDirection, поток, snapMode в GridView. но он был изменен при изменении размера окна.
например, в listmodel есть 5 элементов. И я хочу только 1 столбец при изменении размера окна. Но когда размер высоты окна меньше общей высоты элементов, он изменился на 1 столбец...
Rectangle {
width: 300; height: 200
MouseArea {
anchors.fill: parent
hoverEnabled: true
//onClicked: grid.currentIndex = -1
//onEntered: grid.currentIndex = -1
}
Component {
//Grid {
id: contactDelegate
//Grid {
//columns: 1
Item {
width: grid.cellWidth; height: grid.cellHeight
//columns: 1
MouseArea {
anchors.fill: parent
hoverEnabled: true
onClicked: grid.currentIndex = index
onEntered: grid.currentIndex = index
}
Column {
anchors.fill: parent
Image { source: portrait; anchors.horizontalCenter: parent.horizontalCenter }
Text { text: name; anchors.horizontalCenter: parent.horizontalCenter }
}
}
}
GridView {
id: grid
anchors.fill: parent
cellWidth: 80; cellHeight: 80
//verticalLayoutDirection: GridView.TopToBottom
//flow: GridView.FlowTopToBottom
//snapMode: GridView.SnapToRow
//columns: 1
model: ContactModel {}
delegate: contactDelegate
highlight: Rectangle { color: "lightsteelblue"; radius: 5 }
focus: true
flickableChildren: MouseArea {
anchors.fill: parent
hoverEnabled: true
//onClicked: grid.currentIndex = -1
//onEntered: grid.currentIndex = -1
}
Component.onCompleted: currentIndex = -1
}
}