Qt打开文件对话框同时选中多个文件或单个文件
生活随笔
收集整理的這篇文章主要介紹了
Qt打开文件对话框同时选中多个文件或单个文件
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
Qt中打開單個文件
//str_path為文件路徑 QString str_path = QFileDialog::getOpenFileName(this, tr("選擇轉(zhuǎn)碼文件"), tr("/home"), tr("視頻文件(*.mp4 *.m3u8);;所有文件(*.*);;"));打開多個文件
QString strs; QStringList file_list, output_name; QStringList str_path_list = QFileDialog::getOpenFileNames(this, tr("選擇轉(zhuǎn)碼文件"), 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";}更多參考
轉(zhuǎn)載于:https://www.cnblogs.com/ZY-Dream/p/10571490.html
總結(jié)
以上是生活随笔為你收集整理的Qt打开文件对话框同时选中多个文件或单个文件的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 跨行转账多久到账?转账到账时间有这几种
- 下一篇: 巧用地图