Qt: How to open a link in a user's default browser?

I wonder how to open a link in the user's default browser using Qt (to open it on all platforms (Win Mac Lin))?

+48
c ++ qt
Apr 20 '12 at 16:52
source share
3 answers

In the doc doc: QDesktopServices

http://doc.qt.io/qt-4.8/qdesktopservices.html#openUrl

bool QDesktopServices::openUrl ( const QUrl & url ) [static] 

Opens the given URL in the appropriate web browser for the user's desktop environment and returns true if successful; otherwise returns false.

+53
Apr 20 2018-12-12T00:
source share

You can try this code

 QString link = "http://www.google.com"; QDesktopServices::openUrl(QUrl(link)); 

Read QDesktopServices and QUrl for more information.

+18
Jul 27 '13 at 9:03 on
source share

you're looking for openUrl () in the desktop services class

http://qt-project.org/doc/qt-4.8/QDesktopServices.html

+13
Apr 20 2018-12-12T00:
source share



All Articles