⚠️ Forum Maintenance: Feb 6th, 8am - 14pm (UTC+2)

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.



  • 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