打开文件所在目录并选择该文件

打开文件所在目录并选择该文件

windows实现方式:

QString strTempPath = "/select,";
strTempPath = strTempPath + QDir::toNativeSeparators(strFilePath);
ShellExecuteW(NULL, TEXT("open"), TEXT("Explorer.exe"), strTempPath.utf16(), NULL, SW_SHOWNORMAL);

mac实现方式:

QStringList scriptArgs;
scriptArgs << QLatin1String("-e")
               << QString::fromLatin1("tell application \"Finder\" to reveal POSIX file \"%1\"")
                    .arg(strFilePath);
QProcess::execute(QLatin1String("/usr/bin/osascript"), scriptArgs);
scriptArgs.clear();
scriptArgs << QLatin1String("-e")
               << QLatin1String("tell application \"Finder\" to activate");
QProcess::execute("/usr/bin/osascript", scriptArgs);
posted @ 2015-01-31 21:59  sz_leez  阅读(274)  评论(0编辑  收藏  举报