QProcess::start not working when running from Dolphin in KDE
-
I am running KDE and trying to write my QT application so that it will run by clicking on the icon in Dolphin.
One of the actions the application does is to start another process using QProcess::start. This works fine when I run my QT application from the command line. However, when I do this by clicking on the icon in Dolphin, it appears that the child process is not starting (the QProcess::state call returns 0).
Does anyone know what might be causing this or how to get around it?
Even when I set Dolphin to run the application in a terminal window (which I thought would make it behave the same as when I run in from a terminal manually), it still fails.
Any help is appreciated.
-
Maybe the path is different? Are you sure you point the QProcess to a valid binary? Also, try running with ::startDetached().
-
When you start your app using dolphin I think the "current dir" is set to your homedir. If you open a file from your app this probably assumes the current dir (see QDir::current()) is set to a certain value.
I suggest changing your dir using QApplication::instance()->applicationDirPath() -
Thank you for the responses.
I am fairly certain the source of the problem is not a path issue, as I am using an absolute path when I make the call to QProcess::start.
I did some reading on the QProcess::startDetached method. I could try this, but one limitation about which I've read on that is that the parent process cannot read/write from/to the child process through stdin/stdout, as startDetached doesn't return a QProcess object. I would like to be able to do this.
Starting from the command line is working fine, so I can always just keep doing this. But it would be kind of nice to know why this isn't working.
-
The other main differnce is that dolphin is typically started with the environment you login with. Maybe there is a difference in things like path, ld_library_path etc etc.
Try starting dolphin from the command line (after killing any exising ones) and starting your app from there, this should avoid such issues.
More guesses quickly go into the realms of KDE question, maybe the kde forums could be usefull to :)
-
Thomas,
Thanks, it is likely that this is the problem. The child process being started requires LD_LIBRARY_PATH be set in a certain way. So it is likely that the process is starting and then exiting immediately.
I had tried getting around this by starting the QT application in a script that sourced .bashrc before running the application. I ran this script from Dolphin, but it wasn't sourcing .bashrc correctly. But, yes, I guess this is now more of a KDE question than a QT question, so I will hop over to a KDE forum.
Thanks again.