Qt中打開單個文件
//str_path為文件路徑
QString str_path = QFileDialog::getOpenFileName(this, tr("選擇轉碼文件"), tr("/home"), tr("視頻文件(*.mp4 *.m3u8);;所有文件(*.*);;"));
打開多個文件
QString strs;
QStringList file_list, output_name;
QStringList str_path_list = QFileDialog::getOpenFileNames(this, tr("選擇轉碼文件"), tr("/home"), tr("視頻文件(*.mp4 *.m3u8);;所有文件(*.*);;"));
for (int i = 0; i < str_path_list.size(); i++){
QString str_path = str_path_list[i];
//單個文件路徑
qDebug() << "path=" << str_path;
QFileInfo file = QFileInfo(str_path);
//獲得文件名
QString file_name = file.fileName();
file_list.append(str_path);
output_name.append(file_name);
strs.append(file_name);
strs += "\n";
}
更多參考