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?
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]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With