Important: Please read the Qt Code of Conduct -

Browse web page

  • How to browse to a Q URl ?

  • Moderators

    Use a QWebview for displaying a webpage.
    Use QWebview's setUrl(const QUrl & url) method for setting the URL you wish to display.

  • In Qt4.8.x under the header file "QUrl" (#include <QUrl>) the class has several constructors of which, for your purpose, ' QUrl ( const QString & url ) ' or perhaps ' QUrl ( const QString & url, ParsingMode parsingMode ) ', would be most appropriate, but it depends of what you are looking for.
    Another option is to use th 'QUrl ()' constructor and then use 'setUrl ( const QString & url )' or ' setUrl ( const QString & url, ParsingMode parsingMode )'.
    #include <QUrl> //Qt UR
    #include <memory> // smart pointer
    #include <string>
    int main(){
    std::string url;

    // ..... some other code .....

    std::shared_ptr<QUrl > myUrl;
    std::shared_ptr<QUrl > myUrl(url);

    // ..... some other code .....

    // if the non parameterized constructor was used, use default URL address
    myUrl->setUrl("") ;
    return 0;


    I have NOT checked the code, but it will help you understand the main concept I hope; but if not, keep asking, folks here a very help full.

  • I thank everyone for the answers

Log in to reply