Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Qt - set url link for an image



  • Hello friends,

    I want to put a picture in my form that have a URL link.
    For example, a g+ icon that link to my profile.
    Note: The web browser must be open.

    Thanks a lot.
    Ya Ali.


  • Moderators

    Do the following on click of your image:

    @
    #include <QDesktopServices>
    #include <QUrl>

    void MyWidget::imageClicked()
    {
    QDesktopServices::openUrl(QUrl("http://www.whatever.com"));
    }
    @

    That will use the system default URL handler to open the url. So basically whatever browser the user has set.


Log in to reply