使用类为:
#include <QDirIterator> #include <QDir> #include <QFileInfo> 具体函数为: void ModifyAngle::GetImgs(QString _dir) { QDirIterator it(_dir,QDir::Files|QDir::Dirs|QDir::NoDotAndDotDot); //遍历所有目录和文件 while (it.hasNext())//存在 { QString name = it.next();//读取 QFileInfo info(name); if (info.isDir())//判断是目录 { this->GetImgs(name);//递归 } else { if (info.suffix() == "jpg" || info.suffix() == "bmp" || info.suffix() == "png") { this->plistname_.push_back(name);//符合添加 } } } }
时间: 2024-10-16 19:17:13