QDir - Filter by file name, not extension
-
wrote on 24 Feb 2014, 12:33 last edited by
I would like to list the files in a directory with similar names (not extension).
For example, list all files that sounds like "Apple". (Apple1.txt, Apple2.txt, Apple3.txt)
To list files by extension I would to this:
@
QStringList nameFilter("*.txt");
QDir directory("/home/");
QStringList FilesAndDirectories = directory.entryList(nameFilter);
@But how do I list by file name?
-
@
QStringList nameFilter("Apple*");
@ -
wrote on 24 Feb 2014, 14:37 last edited by
Your default filter is set to NoFilter!!
see definition:
QStringList QDir::entryList(const QStringList & nameFilters, Filters filters = NoFilter, SortFlags sort = NoSort) const
so you can specify the Filters see:
"QDir::Filters":http://qt-project.org/doc/qt-5/qdir.html#Filter-enumat the link is allso an example :-)
best regards
Harry
1/4