[英]How to display images in GridView in descending order in QML?
如何在GridView中按降序显示图像?
我需要显示的图像来自我的串行相机捕获图像的本地目录,我想要做的是在GridView中显示将添加到本地文件夹中的最新图像。
这是我目前的代码:
Rectangle {
visible: true
FolderListModel {
id: folderModel
nameFilters: ["*.jpg"]
folder: "file:///E:/Camera-pics/camera"
}
Component {
id: fileDelegate
Image {
width: gridView.cellWidth - 5
height: gridView.cellHeight - 5
smooth: true
source: fileURL
}
}
GridView {
id: gridView
anchors {
fill: parent
leftMargin: 5
topMargin: 5
}
cellWidth: width / 2
cellHeight: height / 2
model: folderModel
delegate: fileDelegate
}
}
请帮帮我,谢谢你
尝试在FolderListModel
上使用sortReversed
:
FolderListModel {
// ...
sortReversed: true
}
如果需要,您还可以指定sortField
以按日期,名称等排序
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.