码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2015-01-31 23:05:25      阅读:325      评论:0      收藏:0      [点我收藏+]

标签:

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

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);

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

标签:

原文地址:http://www.cnblogs.com/sz-leez/p/4264801.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!