Qt 遍历目录下所有图片

 1 #include <QDirIterator>
 2 #include <QDir>
 3 #include <QFileInfo>
 4 
 5 具体函数为:
 6 void ModifyAngle::GetImgs(QString _dir)
 7 {
 8     QDirIterator it(_dir,QDir::Files|QDir::Dirs|QDir::NoDotAndDotDot); //遍历所有目录和文件
 9     while (it.hasNext())//存在
10     {
11         QString name = it.next();//读取
12         QFileInfo info(name);
13         if (info.isDir())//判断是目录
14         {
15             this->GetImgs(name);//递归
16         }
17     }
18 }
19 else
20 {
21     if (info.suffix() == "jpg" || info.suffix() == "bmp" || info.suffix() == "png")
22     {
23         this->plistname_.push_back(name);//符合添加
24     }
25 }
原文地址:https://www.cnblogs.com/ybqjymy/p/13156316.html