PDA

View Full Version : Mozilla/Firefox remote command



larsli
2nd February 2007, 17:04
I'm trying to control Mozilla or Firefox from QProcess on Linux. I get them to start, but I can't change the URL in an already opened browser. I try the command mozilla -remote "openURL(www.qtcentre.org)" but QProcess just opens another instance of the browser. From the command line it works as it should. Anyone know the syntax for this? This is what I'm doing, it doesn't matter if I use process.start or launch.



if ( !process_started ) {
cout << "Web browser not running. Trying to start" << endl;
QStringList args;
args += "mozilla";
args += rUrl;
process.setArguments( args );
QString buf;
process_started = process.launch( buf );
return process_started;
}

if ( process_started ) {
cout << "Web browser already running. Sending new address to already opened browser." << endl;
QStringList args;
args += "mozilla";
args += "-remote \"openURL(" + rUrl + ")\"";
process.setArguments( args );
QString buf;
process_started = process.launch( buf );
return process_started;
}

wysota
2nd February 2007, 22:21
Lose the quotes around the openUrl command and separate "-remote" from the actual command.

process.setArguments(QStringList()
<< "mozilla"
<< "-remote"
<< "openUrl(http://www.qtcentre.org)"
);

larsli
5th February 2007, 09:23
Losing the quotes did it! Thank you very much for your help. :)