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";}
更多参考