QString stPath = "../../data";
QDir dir(stPath);
QStringList nameFilters;
nameFilters<< "*.jpg" << "*.png";
//QDir::Dirs: find directory
//QDir::Readable find is read files
//QDir::NoDotAndDotDot not find . and ..
//QDir::Name Name sort
QStringList stBranchPath = dir.entryList(QDir::Dirs|QDir::Readable|QDir::NoDotAndDotDot, QDir::Name);
if(stBranchPath.isEmpty())
qDebug("directorys are mpty");
else
{
for(int i = 0; i < stBranchPath.size(); i++)
{
QString tem = stBranchPath.at(i);
qDebug()<<"stBranchPath: "<<dir.filePath(tem);
QDir stDir(dir.filePath(tem));
//nameFilters just find *.jpg and *.png
//QDir::Files: find Files
//QDir::Readable find is read files
//QDir::NoDotAndDotDot not find . and ..
//QDir::Name Name sort
QStringList stFileList = stDir.entryList(nameFilters, QDir::Files|QDir::Readable|QDir::NoDotAndDotDot, QDir::Name);
if(stFileList.isEmpty())
qDebug("files are mpty");
else
{
for(int i = 0; i < stFileList.size(); i++)
{
QString tem = stFileList.at(i);
qDebug()<<"BranchPath fileName: "<<tem;
}
}
}
}
网友评论