QProcess not accepting arguments in MacOS (works in Windows)
-
I am running Qt 5.10 on MacOS 10.13.2
I am trying to open photoshop with one or more selected images in MacOS. In terminal this works:
open "/Users/roryhill/Pictures/4K/2017-01-25_0030-Edit.jpg" -a "Adobe Photoshop CS6"
The following works in Windows but not MacOS:
QString app = "\"/Applications/Adobe Photoshop CS6/Adobe Photoshop CS6.app\""; // diff file path for windows QStringList arguments; arguments << "/Users/roryhill/Pictures/4K/2017-01-25_0030-Edit.jpg"; QProcess *process = new QProcess(); process->start(app, arguments);
In MacOS I get the error: "FailedToStart". If I drop the arguments in the last line and use:
process->start(app);
then photoshop opens, so the path to the photoshop executable is working.
I have also tried using the executable inside the app container:
"/Applications/Adobe Photoshop CS6/Adobe Photoshop CS6.app/Contents/MacOS/Adobe Photoshop CS6"
Again this works to open photoshop but fails when arguments are added.
This also fails:
process->setArguments(arguments); process->setProgram(app); process->start();
Omitting setArguments() fails too using this procedure:
process->setProgram(app); process->start();
Could this be some permissions issue in MacOS?
-
Hi
What happens if you do ?
QDesktopServices::openUrl(QUrl("file:///Users/roryhill/Pictures/4K/2017-01-25_0030-Edit.jpg")); -
Hi
What happens if you do ?
QDesktopServices::openUrl(QUrl("file:///Users/roryhill/Pictures/4K/2017-01-25_0030-Edit.jpg")); -
@mrjj said in QProcess not accepting arguments in MacOS (works in Windows):
QDesktopServices::openUrl(QUrl("file:///Users/roryhill/Pictures/4K/2017-01-25_0030-Edit.jpg"));
That opens the image in preview, so I guess permissions are okay.
-
try to use open.
open -b org.mozilla.firefox "Samsung A3 2017.pdf"
open the pdf file with Firefox
(I don't have photoshop)
Tape "man open" in the Terminal for details.@mpergand said in QProcess not accepting arguments in MacOS (works in Windows):
try to use open.
open -b org.mozilla.firefox "Samsung A3 2017.pdf"
open the pdf file with Firefox
(I don't have photoshop)
Tape "man open" in the Terminal for details.Thanks. I will try this. I have to take a family break and I will report back tomorrow.
-
Hi,
You'll likely have to use the full path to the executable within the application bundle rather than the bundle itself.
-
Hi,
You'll likely have to use the full path to the executable within the application bundle rather than the bundle itself.
@SGaist said in QProcess not accepting arguments in MacOS (works in Windows):
Hi,
You'll likely have to use the full path to the executable within the application bundle rather than the bundle itself.
Thanks for the suggestion. As I mentioned in my original post I have tried this and it did not work.
I think my issue is related to how MacOS manages file locks. I can get the code to work with preview once and then the next time I get an error "the file couldn’t be opened because you don’t have permission to view it." This seems to be a common problem where preview maintains a lock on the file after the application has been closed. I'm going to take a look at QLockFile to see if it can help.
-
@SGaist said in QProcess not accepting arguments in MacOS (works in Windows):
Hi,
You'll likely have to use the full path to the executable within the application bundle rather than the bundle itself.
Thanks for the suggestion. As I mentioned in my original post I have tried this and it did not work.
I think my issue is related to how MacOS manages file locks. I can get the code to work with preview once and then the next time I get an error "the file couldn’t be opened because you don’t have permission to view it." This seems to be a common problem where preview maintains a lock on the file after the application has been closed. I'm going to take a look at QLockFile to see if it can help.
@Rory_1 Update: I have partially solved my problem by resetting permissions on my macbook.
diskutil resetUserPermissions / `id -u`
The code now works consistently for all applications, including adobe Bridge, except photoshop. I assumed (bad plan) that photoshop accepted command line arguments (and it does in windows) but might not in MacOS.
I do not believe the remaining issues are related to QProcess so I am marking this as solved.