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

Check if all children of QNetworkAccessManager is running



  • How to check if all QNetworkReply of a QNetworkAccessManager is running?

    I tried like this but I get a bunch of errors:

        auto children = manager.findChildren<QNetworkReply *>();
    
        std::all_of(children.begin(), children.end(), [](auto child) {
    
        });
    

  • Moderators

    @Mr-Gisa Going to assume (since I'm not sure) that QNetworkReply * are parented to the QNetworkAccessManager. In which case findChildren will work ... if that assumption is correct here is how you would do it:

    foreach (QNetworkReply *reply, manager.findChildren<QNetworkReply *>())
    {
       if (reply->isRunning())
       {
          // this request is still running, do whatever you want here
       }
    }
    


  • I solved it by doing:

    auto replies = manager.findChildren<QNetworkReply *>();
    auto running = std::all_of(replies.begin(), replies.end(), [](auto child) {
        return child->isRunning();
    });
    

Log in to reply