代码如下:
#include #include #include int main(int argc, char *argv[]){ QCoreApplication a(argc, argv); QString dirpath = "F:/Test/"; QDir dir(dirpath); QStringList nameFilters; nameFilters << "*.MP4" << "*.flv"; //将过滤后的文件名称存入到files列表中 QStringList files = dir.entryList(nameFilters, QDir::Files|QDir::Readable, QDir::Name); for(int i = 0; i< files.size(); ++i) { QString temp =files.at(i); qDebug() << "filename: " << temp; } return a.exec();}