qt5 - Qt: QNetworkAccessManager dont send request -
i used qnetworkaccessmanager handle send http request:
void f() { qnetworkrequest request( qurl( address ) ); qnetworkaccessmanager mng; mng.get(request); //qeventloop().exec(); } void main() { ... f(); ... } if without line qeventloop().exec();, app not send request. if line qeventloop().exec();, will. don't understan why?
can clear me?
thank much! (p/s: have seen link: sending http request using qnetworkaccessmanager)
void f() { static qnetworkrequest request( qurl( address ) ); static qnetworkaccessmanager mng; mng.get(request); } void main() { ... f(); ... } i think because qnetworkaccessmanager asynchronous , need time send request. require, url, query, ... destroyed when out of scope. -> need in scope when qnetworkaccessmanager send request (use qeventloop().exec(); ) or let require, url, query, ... persistent (declare static).
Comments
Post a Comment