winter
winter

Reputation: 43

How to start application(path with space) using QProcess on mac OSX?

It goes well when using QProcess to start a program if its path without space.
eg:

QProcess app;
app.startDetached("open /Users/test/Desktop/MyTest/Hello.app");

But, it doesn't work if the program path containing spaces.
eg:

QProcess app;
app.startDetached("open /Users/test/Desktop/My Test/Hello.app");

Someone can help me and tell me how to start a program with space in its path?
Thanks!

Upvotes: 0

Views: 3833

Answers (1)

TheDarkKnight
TheDarkKnight

Reputation: 27611

You need to use quotes in the string for the path:-

app.startDetached("open \"/Users/test/Desktop/My Test/Hello.app\"");

Without the quotes, the space will suggest the next part of the path as a 2nd parameter passed to the call to open.

Upvotes: 4

Related Questions