PDA

View Full Version : QProcess state



patcito
17th January 2006, 19:50
I have a code to detect browser like this:



QProcess pProcess;
QString webBrowserCmd;
int return_value =0;
if ( return_value !=2 ) {
webBrowserCmd.clear();
webBrowserCmd.append( "mozilla-firefox " );
webBrowserCmd.append( url );
pProcess.start(webBrowserCmd);
return_value = pProcess.state();
}
// Try with Mozilla
else if ( return_value !=2 ) {
webBrowserCmd.clear();
webBrowserCmd.append( "mozilla " );
webBrowserCmd.append( url );
pProcess.start(webBrowserCmd);
return_value = pProcess.state();
}
// Try with galeon
else if ( return_value !=2 ) {
webBrowserCmd.clear();
webBrowserCmd.append( "galeon " );
webBrowserCmd.append( url );
pProcess.start(webBrowserCmd);
return_value = pProcess.state();
}

The doc says QProcess::state() return 2 if the process is not running.
If the browser doesn't exists I try another one, I use pProcess.state() value for this but I'm note sure it will return 1 or 2 in case of failure. Will it always return 2 if the browser doesn't exist? I'm afraid it could return 1 because the process might still be running even if the command failed. Any idea if this is the right way to do it?

Thanx in advance

Pat

wysota
17th January 2006, 20:56
How about searching $PATH to locate appropriate commands?