打开文件夹,并选择指定文件
//打开文件夹,并且选择指定文件
QString fileName = ui->lineEdit->text();
if(fileName.isEmpty())
return;
QProcess process;
fileName.replace("/","\\");
QString cmd = QString("explorer.exe /select,\"%1\"").arg(fileName);
qDebug()<<cmd;
process.startDetached(cmd);
只打开文件夹,不需要选择
QString fileName = ui->lineEdit->text();
if(fileName.isEmpty())
return;
fileName.remove(fileName.split("/").last());
QDesktopServices::openUrl(QUrl::fromLocalFile(fileName));//支持中文路径
其中的lineedit保存的是一个文件的绝对路径。