Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QNetworkReply asycn problem
Qt 6.11 is out! See what's new in the release blog

QNetworkReply asycn problem

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 943 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Z Offline
    Z Offline
    zolidznake
    wrote on last edited by
    #1

    Hello guys,

    I am trying in get a xml response from a server using QNetworkReply and because the response is done async, when i need the value returned by an object and i put it in a string, the value from string si empty "".

    someone could help me with a sugestion in how i can fix this async problem ?

    Kind Regards,
    Silviu

    1 Reply Last reply
    0
    • V Offline
      V Offline
      vivekmalik2466
      wrote on last edited by
      #2

      Refer this link will help you
      http://qt-project.org/doc/qt-4.7/qnetworkaccessmanager.html

      you can also try this:-

             @ QNetworkRequest request;
                  request.setUrl(QUrl(fileURL));
                  QNetworkAccessManager *downloadmanager = new QNetworkAccessManager(this);
                  downloadreply = downloadmanager->get(request);
      
                  connect(downloadreply,SIGNAL(downloadProgress(qint64,qint64)),this,SLOT(onDownloadProgress(qint64,qint64)));
                  connect(downloadmanager,SIGNAL(finished(QNetworkReply*)),this,SLOT(onFinished(QNetworkReply*)));
      

      void class::onFinished(QNetworkReply * reply )
      {
      switch(reply->error())
      {
      case QNetworkReply::NoError:
      {
      QByteArray Data=reply->readAll();
      //you have all the data in Data
      }break;
      default:{
      //handle exception;
      };
      }
      }
      }
      @

      1 Reply Last reply
      0
      • Z Offline
        Z Offline
        zolidznake
        wrote on last edited by
        #3

        ok, I already have done this.

        But , for example, if i want to move Data in a method named QString getData() and then i create a new object and after this i call getData() the return string will be empty .

        Regards,
        Sil

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved