在QT中仅获取文件而不获取目录? [英] Get only files but not directories in QT?
本文介绍了在QT中仅获取文件而不获取目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我这样做时:
QDir myDir("/home/some/location");
QStringList filesList = myDir.entryList("*");
它同时返回该位置内的文件和目录。但是我只想要文件。并且文件可以具有任意扩展名。有什么想法吗?
it is returning both the files and the directories inside that location. But I want only files. And the files can have arbitrary extensions. Any ideas?
推荐答案
使用 QDir :: entryInfoList 返回QFileInfo对象的列表,然后检查每个对象的状态,也可以使用过滤器仅返回对象的列表。文件和/或目录
Use QDir::entryInfoList to return a list of QFileInfo objectsd and then check the state of each of them, you can also use filters to only return a list of files /and/or dirs
这篇关于在QT中仅获取文件而不获取目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文