Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. International
  3. India
  4. Downloading data ZIP file from website
Forum Updated to NodeBB v4.3 + New Features

Downloading data ZIP file from website

Scheduled Pinned Locked Moved India
2 Posts 2 Posters 2.3k 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.
  • R Offline
    R Offline
    rambabuy
    wrote on last edited by
    #1

    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
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

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

      (Z(:^

      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