myWallJSON
myWallJSON

Reputation: 9502

How to open a link in a default user browser in Qt?

I wonder how to open a link in a default user browser using Qt (that would open it across all platforms (Win Mac Lin))?

Upvotes: 76

Views: 40770

Answers (3)

jdi
jdi

Reputation: 92567

In the 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.

Upvotes: 91

Tan Viet
Tan Viet

Reputation: 2113

You can try this code

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

Read QDesktopServices and QUrl to get further information.

Upvotes: 40

Nathan Boyd
Nathan Boyd

Reputation: 589

you are looking for openUrl() in the desktop services class

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

Upvotes: 14

Related Questions