Deleting 'QNetworkReply *' returned by QNe

2019-07-20 19:39发布

问题:

QNetworkAccessManager::post function returns network reply object, is caller required to delete this or network access manager will take care of deleting it.?

回答1:

From the documentation:

Note: After the request has finished, it is the responsibility of the user to delete the QNetworkReply object at an appropriate time. Do not directly delete it inside the slot connected to finished(). You can use the deleteLater() function.



回答2:

you can do it in slot if readyRead

   reply->abort();
    reply->deleteLater();
    reply->manager()->deleteLater();


标签: qt qt4