为什么 GridView 项目不换行?

Why GridView item don't wrap?

我在我的 qml 代码中使用 GridView,但它只在一行中显示所有项目,但我不想要它。您可以在下图中看到: 这是我的代码:

import QtQuick 2.8
import QtQuick.Controls 2.1
import Qt.labs.folderlistmodel 2.1

ApplicationWindow{
    id: a
    width: 480
    height: 640
    FolderListModel{
        id : listModel
        folder: "/home/muhammad/Pictures"
        nameFilters: ["*.jpg"]
    }
    Component{
        id: dd
        Image {
            id: m
            width: a.width/3
            height: width
            source: filePath
        }
    }

    GridView{
        verticalLayoutDirection: GridView.TopToBottom
        layoutDirection: Qt.LeftToRight
        anchors.fill: parent
        flow: GridView.FlowLeftToRight
        model: listModel
        delegate: dd
    }

}

我该如何解决?

GridView 中每个单元格的大小由 cellWidth and cellHeight 决定。默认像元大小为 100x100。请注意,单元格大小决定了视图的布局。代表们可以决定如何覆盖为每个单元保留的区域。例如,您可能希望将 Image-delegate 的大小调整为 cellWidthcellHeight,并将其 fillMode 设置为 Image.PreserveAspectFit

GridView {
    id: gridView

    cellWidth: 200
    cellHeight: 200

    delegate: Image {
        width: gridView.cellWidth
        height: gridView.cellHeight
        fillMode: Image.PreserveAspectFit
    }
}