Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

When qnetworkreply is delete after request from QNetworkAccessManager::get(QNetworkRequest request (url))?



  • I am accessing the network using QNetworkRequest , QNetworkAccessManager, and QNetworkReply.

    At which place m_reply delete? it will delete when manager delete or it will delete at any other place?

    QNetworkAccessManager* manager = new QNetworkAccessManager();
    auto  m_reply = manager ->get(QNetworkRequest request (https://www.google.com));
    
    // Here  read all the data from m_reply and call m_reply->close();
    
    // again use same manage for request data 
    m_reply = manager ->get(QNetworkRequest request (https://www.facebook.com));
    
    

    Can I use m_reply variable in this way?


  • Lifetime Qt Champion

    Hi,

    Usually you don't store the reply but rather connect its signals to lambdas, do the processing there and then call deleteLater on it once you are done.


  • Lifetime Qt Champion

    Hi,

    Usually you don't store the reply but rather connect its signals to lambdas, do the processing there and then call deleteLater on it once you are done.