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

C++Qt

C++ Problem Overview


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

C++ Solutions


Solution 1 - C++

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.

Solution 2 - C++

You can try this code

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

Read QDesktopServices and QUrl to get further information.

Solution 3 - C++

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

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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionmyWallJSONView Question on Stackoverflow
Solution 1 - C++jdiView Answer on Stackoverflow
Solution 2 - C++Tan VietView Answer on Stackoverflow
Solution 3 - C++Nathan BoydView Answer on Stackoverflow