Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Downloading data ZIP file from website

    India
    2
    2
    1993
    Loading More Posts
    • 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.
    • R
      rambabuy last edited by

      Hi Experts ,

      I am downloading data from www.nseinda.com
      and the link is "http://www.nseindia.com/content/historical/EQUITIES/2015/JAN/cm12JAN2015bhav.csv.zip"

      But i am downloading 0 size file ..

      anything wrong ? or any working program for downloading files from web?

      @downloader::downloader(QObject *parent) :
      QObject(parent)
      {
      qDebug() << FILE<<" : " << FUNCTION << " Entering";
      myprocedure();
      qDebug() << FILE<<" : " << FUNCTION << " Leaving";
      }

      void downloader::downloadFile(const QString &url, const QString &aPathInClient)
      {
      qDebug() << FILE<<" : " << FUNCTION << " Entering";
      QNetworkAccessManager m_NetworkMngr;
      QNetworkReply *reply= m_NetworkMngr.get(QNetworkRequest(url));
      QEventLoop loop;
      QObject::connect(reply, SIGNAL(finished()),&loop, SLOT(quit()));
      loop.exec();
      QUrl aUrl(url);
      QFileInfo fileInfo=aUrl.path();

      QFile file(aPathInClient+"\\"+fileInfo.fileName(&#41;&#41;;
      file.open(QIODevice::WriteOnly&#41;;
      file.write(reply->readAll(&#41;);
      
      delete reply;
      qDebug() << __FILE__<<"   :  " << __FUNCTION__ << " Leaving";
      

      }
      void downloader::myprocedure()
      {
      qDebug() << FILE<<" : " << FUNCTION << " Entering";

      QString path;
      QString localpath;
      QMessageBox msgBox;
      QMessageBox msgBox2;
      
      path = QStandardPaths::writableLocation(QStandardPaths::HomeLocation);
      
      path = "C:/Users/ryerajan/build-untitled2-Desktop_Qt_5_3_MinGW_32bit-Debug/base/download/cm01OCT2014bhav.dbf.zip";
      
      localpath = path;
      

      // QMessageBox msgBox2;
      msgBox2.setText("You can download the update from the web.");
      msgBox2.setInformativeText("Do you want to download the file now?");
      msgBox2.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
      msgBox2.setDefaultButton(QMessageBox::Yes);
      int ret = msgBox2.exec();

      if (ret == QMessageBox::Yes&#41; {
      
          downloadFile ("http://www.nseindia.com/content/historical/EQUITIES/2014/OCT/cm01OCT2014bhav.dbf.zip", localpath&#41;;
      
          msgBox.setText("Your file should be updated now"&#41;;
          msgBox.exec(&#41;;
      
      }
      
      else {
      
          // Do something else
      
      }
      
      qDebug(&#41; << __FILE__<<"   :  " << __FUNCTION__ << " Leaving";
      

      }@

      1 Reply Last reply Reply Quote 0
      • sierdzio
        sierdzio Moderators last edited by

        Please do not "double post":https://qt-project.org/forums/viewthread/51978/.

        (Z(:^

        1 Reply Last reply Reply Quote 0
        • First post
          Last post