I have a code to detect browser like this:
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();
}
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();
}
To copy to clipboard, switch view to plain text mode
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
Bookmarks