QNetworkRequest problem



  • hey im new to QT.

    im trying to load html from a url and i get an error on just the first line

    My guess is that i haven't set up QTCreator correctly?

    The code that is causing the error is this 1 liner.

    @
    QNetworkRequest *request = new QNetworkRequest(QUrl("http://www.google.com"));
    @

    Error:
    Golfllink.obj:: error: unresolved external symbol "__declspec(dllimport) public: __thiscall QNetworkRequest::QNetworkRequest(class QUrl const &)" (_imp??0QNetworkRequest@@QAE@ABVQUrl@@@Z) referenced in function "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall Golflink::getHtmlByUrl(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?getHtmlByUrl@Golflink@@QAE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V23@@Z)

    [EDIT: code formatting, please use @-tags, Volker]



  • You are missing QtNetwork library. Add

    @
    QT += network
    @

    to your .pro file and read about Qt way of "Declaring Qt Libraries":ttp://doc.qt.nokia.com/4.7/qmake-project-files.html#declaring-qt-libraries in qmake .pro files.

    "QNetworkRequest":http://doc.qt.nokia.com/4.7/qnetworkrequest.html states, like all other classes in the API reference docs, which module they are in. These modules have to be added to the QT variable in the .pro file.



  • that solved it

    thanks!


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.