#include<QFileInfoList>
#include<QDir>

void patientpreview::getfile()
{
QDir dir("F:\\qt-eye-fundus\\patientmanage");
dir.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks);
dir.setSorting(QDir::Size | QDir::Reversed);

QFileInfoList list = dir.entryInfoList();
for (int i = 0; i < list.size(); ++i) {
QFileInfo fileInfo = list.at(i);
qDebug() << qPrintable(QString("%1 %2").arg(fileInfo.size(), 10)
.arg(fileInfo.fileName()));
QString filepath;
filepath.append(fileInfo.path());
filepath+="\\"+fileInfo.fileName();
qDebug()<<filepath;

}
}
上面没有进入子文件夹进行查找
QFileInfoList GetFileList(QString path)
{
QDir dir(path);
QFileInfoList file_list = dir.entryInfoList(QDir::Files | QDir::Hidden | QDir::NoSymLinks);
QFileInfoList folder_list = dir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot);

for(int i = 0; i != folder_list.size(); i++)
{
QString name = folder_list.at(i).absoluteFilePath();
QFileInfoList child_file_list = GetFileList(name);
file_list.append(child_file_list);
}

return file_list;
}