环境
VS2015 qt5.9.7 64位
功能
通过对话框选定文件夹,获取该文件夹内所选图片名称
代码
1 QStringList FileNames; 2 FileNames = QFileDialog::getOpenFileNames(this, tr("Open File"), 3 QCoreApplication::applicationDirPath(), 4 tr("ALL(*.png; *.jpg; *.bmp; *.tif; *.tiff);;PNG(*.png);;JPG(*.jpg);;BMP(*.bmp);;TIF(*.tif);;TIFF(*.tiff))")); 5 6 if (FileNames.size() == 0) 7 { 8 QMessageBox::critical(this, tr("ERR"), tr("Empty")); 9 return; 10 } 11 12 qDebug() << "FileNames" << FileNames;
关键函数:
static QStringList getOpenFileNames(QWidget *parent = nullptr, const QString &caption = QString(), const QString &dir = QString(), const QString &filter = QString(), QString *selectedFilter = nullptr, Options options = Options());