PDA

View Full Version : add link that open web browser on unix



asafb
4th October 2006, 16:25
hi
I wish to open a web browser in unix ( mozilla) from QT .
I saw that this question was asked here before and i used the answer in mu code .
BUT
it doesn't work for me. the process crash ( normalExit return 0 ) and no browser is open.

How can i figure out why it does not work ??
more details :
I am working on sun OS
which i am loged in using the rlogin command
the DISPLAY env is set correctlly in my ~/.cshrc file.

here is the code that i copy from this forum :
and what does Q_UNUSED(this) mean ?



bool result = false;
QUrl rUrl("http://www.cnn.com");
QString sUrl = rUrl;
QApplication::setOverrideCursor(Qt::BusyCursor);

Q_UNUSED(this);
// Try a range of browsers available on UNIX, until we (hopefully)
// find one that works. Start with the most popular first.
QProcess process;
bool process_started = false;

process.setArguments(QStringList() << "mozilla" << sUrl );
process_started = process.start();

QApplication::restoreOverrideCursor();

return;

jacek
4th October 2006, 16:49
How can i figure out why it does not work ??
You create QProcess instance on the stack and it gets destroyed when it goes out of scope.


and what does Q_UNUSED(this) mean ?
You can use it to suppress warnings about unused function arguments.

Brandybuck
4th October 2006, 19:25
Qt 4.2 (released yesterday) includes QDesktopServices. This allows you to open URLs in a desktop-neutral manner. Give it an URL and it hands it off to the desktop to open, using the user's application preference.

For example, an application of mine uses it for a website in the About Box. It opens in Firefox under Windows, Konqueror under KDE, and Safari under Mac, because those are my preferences.

bwindorski
24th January 2009, 08:10
And nothing under gnome...or not for me anyways...

jpn
24th January 2009, 13:39
And nothing under gnome...or not for me anyways...
Does your link have a proper scheme (eg. http)? What happens if you issue command "xdg-open http://www.qtcentre.org" in terminal?

bwindorski
25th January 2009, 08:42
Yeah that opened a browser thanks. I've had little to no luck with the QUrl or QDesktopServices.

jpn
25th January 2009, 16:39
Yeah that opened a browser thanks. I've had little to no luck with the QUrl or QDesktopServices.
Well then the problem must be with the URL because that's what QDesktopServices does behind the scenes. Make sure the link contains the scheme as I mentioned.

bwindorski
25th January 2009, 21:55
QDesktopServices::openUrl ( QUrl ( "http://www.google.com" ) );

Its something with my GCofig

this is the dbug-output

GConf Error: Failed to contact configuration server; some possible causes are that you need to enable TCP/IP networking for ORBit, or you have stale NFS locks due to a system crash. See http://www.gnome.org/projects/gconf/ for information. (Details - 1: Failed to get connection to session: '=' character not found or has no value following it)

not sure what it is looking into it.

sorry asafb I'm not trying to hijack your post.