Hey,
I need to launch some external applications from my own program. So here's the simple question, which is preferred way to launch those applications QDesktopServices or QProcess?
I have done a small test with these and I would like to use QDesktopServices for this, but there seems to be some problem when trying to launching application executables.
Here's some code to clear things up...
Opening default web browser with some web page. This does the job as expected, good
QDesktopService
::openUrl(QUrl("http://www.qtcentre.org"));
QDesktopService::openUrl(QUrl("http://www.qtcentre.org"));
To copy to clipboard, switch view to plain text mode
This is obviously because these kind of "resources" are marked to be opened with the web browser
Then there's also ability to open some files, for example self-executable JAR packages, with the same method
QDesktopService
::openUrl(QUrl("file:////path/to/the/package.jar"));
QDesktopService::openUrl(QUrl("file:////path/to/the/package.jar"));
To copy to clipboard, switch view to plain text mode
This also goes as expected since Java Runtime is selected to be associated with this file type
Now, here comes the odd part. I would expect next code sample...
QDesktopService
::openUrl(QUrl("file:////path/to/the/executable"));
QDesktopService::openUrl(QUrl("file:////path/to/the/executable"));
To copy to clipboard, switch view to plain text mode
... to start the application but it won't, instead it says in the console: "Error showing url: No application is registered as handling this file". This happens only in Linux, with Windows the executable is launched as expected... (of course with Windows the path in QUrl is different)
I understand that there's no application associated with these kind of files (executables), but shouldn't the system understand that the executable is just meant to be launched 
Also the code...
QString program
= "/path/to/the/executable";
process->start(program, arguments);
QString program = "/path/to/the/executable";
QStringList arguments;
QProcess *process = new QProcess(this);
process->start(program, arguments);
To copy to clipboard, switch view to plain text mode
is able to launch the application just fine.
So, do I have to use these both tehcniques to achieve what I want? Or is there a way to get the QDesktopServices to launch executables as expected, also in Linux? Maybe something to tweak from the Linux's settings? (I'm using Ubuntu, btw)
-Tepi
Bookmarks