tags:

views:

624

answers:

1

I have a "start page" on my application that is just a QWebView widget that downloads a page from my server.

When the user clicks on a link I'd like it to open in their default browser, not in the widget.

Is there a way to do this with QWebView? Or should I take a different approach?

+3  A: 

Just call QWebPage::setLinkDelegationPolicy(QWebPage::DelegateAllLinks) then connect the signal QWebView::linkClicked (const QUrl & url) to a slot, and in the slot execute the browser. Finding out what the default browser is, is slightly more complicated and depends on which desktop the user is running. The environment variable BROWSER often contains the default.

Or use QDesktopServices::openUrl [as suggested by gnud in a comment]

PiedPiper
To open a browser, use QDesktopServices::openUrl - http://doc.trolltech.com/4.5/qdesktopservices.html#openUrl
gnud