Important: Please read the Qt Code of Conduct -

[Solved] createRequest does not finish

  • I can not do QNetworkAccessManager::createRequest finalize request. I tried finished(QNetworkRequest), but nothing happens, see how was the WebInspector:


    The request is pending and never ends.

    What am I doing wrong?

    My code:

    @QNetworkReply * myNAM::createRequest(Operation op, const QNetworkRequest &request, QIODevice *outgoingData){
    QNetworkAccessManager *n = new QNetworkAccessManager();

     QNetworkRequest req(request.url());
     const QList<QByteArray>a = request.rawHeaderList();
     int j = a.length();
     int i=0;
     QList<QNetworkCookie> cookies = CookiesGlobals->cookiesForUrl(request.url());
     QNetworkReply *p;
     if(op==PostOperation) {
      const QByteArray data = outgoingData->readAll();
      p = n->post(req, data);
     } eles {
      p = n->get(req);
     QEventLoop loop;
     connect(p, SIGNAL(finished()), &loop, SLOT(quit()));
     QVariant statusCode = p->attribute(QNetworkRequest::HttpStatusCodeAttribute&#41;;
     if (statusCode.isValid()){
      int status = statusCode.toInt();
      qDebug() << "FB: " status;
     } else {
      qDebug() << "FB: statusCode isInvalid";
     return p;

  • Solution, removed QEventLoop, update code:

Log in to reply