Sending HTTP Header Info with Qt QNetworkAccessManager

后端 未结 1 1149
暗喜
暗喜 2021-01-19 05:08

I have the following code, and I would like to add some HTTP header info along with the call. Anyway that I can do that?

void NeoAPI::call(QString apiCall)         


        
相关标签:
1条回答
  • 2021-01-19 06:04

    Yes, see the documentation of QNetworkRequest.

    You'll want to do something like:

    QNetworkRequest request(url);
    request.setHeader( QNetworkRequest::ContentTypeHeader, "some/type" );
    request.setRawHeader("Last-Modified", "Sun, 06 Nov 1994 08:49:37 GMT");
    manager->get( header );
    

    Also, if I wasn't using these inside a class, what would the this in the connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(netReplyFinished(QNetworkReply*))); be?

    It wouldn't be anything. To connect a signal to a slot, that slot must be a member function of some object. The Qt primer on signals and slots explains this.

    0 讨论(0)
提交回复
热议问题