HTTP request



  • Hello, I try to create HTTP request in Qt, this is my include section:

    #include "QHash"
    #include "QFile"
    #include "QCryptographicHash"
    #include "QtNetwork/QNetworkRequest"
    #include "QtNetwork/QNetworkAccessManager"
    #include "QUrl"
    #include "QUrlQuery"
    #include "QDebug"
    

    This is code:

    QUrl url("https://api.parse.com/1/login");
    QUrlQuery query;
    
    query.addQueryItem("username", "test");
    query.addQueryItem("password", "test");
    
    url.setQuery(query.query());
    
    QNetworkRequest request(url);
    
    request.setRawHeader("X-Parse-Application-Id", "myappid");
    request.setRawHeader("X-Parse-REST-API-Key", "myapikey");
    
    QNetworkAccessManager *manager = new QNetworkAccessManager(this);
    manager->get(request);
    

    and there are errors:

    Errors

    What is wrong with it, please?


  • Qt Champions 2017

    hi @t0msk,

    have you added QT += network in your .pro file?



  • @aha_1980 Thank you, I forgot :) When I need to add that libraries into .pro file?


  • Moderators

    @t0msk said in HTTP request:

    @aha_1980 Thank you, I forgot :) When I need to add that libraries into .pro file?

    It is easy to forget libraries to add qmake. Most of us forget. However, it isa good advice to check the libraries setting when you get undefined references for Qt libs.

    Please mark your thread as "solved"


Log in to reply
 

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