Sending an HTTP request using QNetworkAccessManager

前端 未结 3 1825
闹比i
闹比i 2020-12-22 12:27

I\'ve got a problem trying to send a request using QNetworkAccessManager from a QObject derived class.

Firstly in my constructor I do the following:

         


        
3条回答
  •  不知归路
    2020-12-22 13:12

    I think this is because QNetworkAccessManager is asynchronous and need the time to send the request. But require, url, query, ... is destroyed when out of scope.
    -> we need in scope when QNetworkAccessManager do send request (use QEventLoop().exec(); ) or let require, url, query, ... is persistent (declare it with static). See: Qt: QNetworkAccessManager dont send request

提交回复
热议问题