Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the list of image files only in a folder

Tags:

qt

I want to get the names of image files (*.png, *.jpg, *.bmp) from a folder.

What I could do so far is this :

 fileInfoList = dir.entryInfoList(QDir::Files|QDir::NoDotAndDotDot);

But how to get only the *.png, *.bmp and *.jpg files ?

like image 339
Barshan Das Avatar asked Oct 25 '25 15:10

Barshan Das


1 Answers

Something like this should work;

 QStringList filters;
 filters << "*.png" << "*.jpg" << "*.bmp";
 fileInfoList = dir.entryInfoList(filters, QDir::Files|QDir::NoDotAndDotDot);

See this for more info.

You can also use the QDir::setNameFilters function to set the filters.

like image 113
thuga Avatar answered Oct 27 '25 16:10

thuga



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!