开发者

Get only files but not directories in QT?

When I do this:

QDir myDir("/ho开发者_如何学JAVAme/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?


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


Use this

QDir recoredDir("YOUR DIRECTORY");
    QStringList allFiles = recoredDir.entryList(QDir::NoDotAndDotDot | QDir::System | QDir::Hidden  | QDir::AllDirs | QDir::Files, QDir::DirsFirst);//(QDir::Filter::Files,QDir::SortFlag::NoSort)

;

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜