Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/qt/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Macos qt能否在Mac上打开finder并在打开的finder窗口中选择(突出显示)一些文件?_Macos_Qt_Select_Applescript_Finder - Fatal编程技术网

Macos qt能否在Mac上打开finder并在打开的finder窗口中选择(突出显示)一些文件?

Macos qt能否在Mac上打开finder并在打开的finder窗口中选择(突出显示)一些文件?,macos,qt,select,applescript,finder,Macos,Qt,Select,Applescript,Finder,在mac上,我的应用程序在一个文件夹中为用户创建一些文件,然后我需要向用户显示这些文件。我可以通过QDesktopServices::openUrl使用finder打开文件夹,但我不能选择(突出显示)刚刚在打开的finder窗口中创建的文件 我尝试了以下代码: QStringList scriptArgs; scriptArgs << QLatin1String("-e") << QString::fromLatin1("tell applicati

在mac上,我的应用程序在一个文件夹中为用户创建一些文件,然后我需要向用户显示这些文件。我可以通过
QDesktopServices::openUrl
使用finder打开文件夹,但我不能
选择(突出显示)
刚刚在打开的finder窗口中创建的文件

我尝试了以下代码:

QStringList scriptArgs;
scriptArgs << QLatin1String("-e")
           << QString::fromLatin1("tell application \"Finder\" to select POSIX file \"%1\"")
                                     .arg(filePath);
QProcess::execute(QLatin1String("/usr/bin/osascript"), scriptArgs);

scriptArgs.clear();
scriptArgs << QLatin1String("-e")
           << QLatin1String("tell application \"Finder\" to activate");
QProcess::execute("/usr/bin/osascript", scriptArgs);`
QStringList脚本参数;

scriptArgs例如,您可以通过传递对象列表来告诉Finder选择多个项目

tell application "Finder" to select {POSIX file "/Applications/Calendar.app", POSIX file "/Applications/Contacts.app"}

(您可以使用
/Applications/Utilities/Script Editor.app
)玩转这类脚本)

我已经完成了以下操作:

    NSMutableArray *fileURLs = [NSMutableArray arrayWithCapacity:fileList.size()];

for(int i=0; i<fileList.size(); i++)
{
    [fileURLs addObject:[NSURL fileURLWithPath:[NSString stringWithCString:fileList.at(i).toUtf8().data() encoding:4] isDirectory:false]];
}

[[NSWorkspace sharedWorkspace] activateFileViewerSelectingURLs:fileURLs];
NSMutableArray*fileurl=[NSMutableArray阵列容量:fileList.size()];
对于(int i=0;i