I have a QFileInfoList (list) that contains info about a directory and its file
QFileInfoList list = directory.entryInfoList();
How can I apply filters to remove everything except image file(jpg, gif, png etc.) ?
Here is a simple foreach loop that only removes everything that is not a file
foreach (QFileInfo f, list){
if (!f.isFile()){
list.removeOne(f);
}
How can I apply filters to remove everything except image file(jpg, gif, png etc.) ?
QDir::entryInfoList() takes name filters, if you're comfortable determining images by extension:
QStringList nameFilter;
nameFilter << "*.png" << "*.jpg" << "*.gif";
QFileInfoList list = directory.entryInfoList( nameFilter, QDir::Files );
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With