[Development] RFC: QProcess variant or separate class for launching applications "GUI-style"

René J.V. Bertin rjvbertin at gmail.com
Fri Jan 8 11:09:41 CET 2016

On Friday January 08 2016 09:03:36 Ziller Eike wrote:

>> This is something that I think we have not yet taken into consideration. It 
>> doesn't necessarily matter for a "startDetached" form of launching though,
>If you just care about starting an application and being notified when it finishes, without the need for output/input streams or PIDs, then you can probably just run “/usr/bin/open -n -W <yourappbundle>"

True, or no, that'd rather be "/usr/bin/open [-n] -W -a appbundle|bundle-exec". It wouldn't always be trivial to get the invocation just right, as that is a wrapper to LSOpenURLWithRole() whereas we'd probably use something more simple, with less ambiguous specification of the arguments. Besides, we identified a need to know the pid and also to be notified of process termination.

FWIW, I did manage to write a short enough AppleScript routine to hardcode a command that pipes it into /usr/bin/osascript and that activates the launched application if it's a GUI application. It works but is not very elegant as AppleScript was never designed for this role: it requires polling (in the AppleScript routine) and an external termination timer (or a more complex script that adds a timeout to the polling loop).
It's something that might be added to QMacExtras though, or a repository of contributed stuff if something like that exists, because it does have the advantage of working on the result of a launch procedure, regardless of how the launch was done. Then again, if AppleScript is to make its appearance in Qt it'd probably be more appropriate to provide a full bridge to it in QMacExtras ... but let's forget I said that for now ;)


More information about the Development mailing list