Results 1 to 3 of 3

Thread: Downloading file problem

  1. #1
    Join Date
    Aug 2012
    Posts
    19
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Downloading file problem

    Hello,
    im trying to develop download app, but I stuck on following problem:

    1)I sen a download request by QNetworkAccessManager
    2)On finished event I got QNetwork *reply which size is correct
    3)but the size of: reply->readAll().length() is incorrect and when I save the file is too small.

    Does anywone know where is the problem or what Im doing wrong?

    BR
    Tomek

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Downloading file problem

    Hard to say without seeing your code. However, if you do this,
    Qt Code:
    1. qDebug() << reply->readAll().length();
    2. // then open file and
    3. file.write(reply->readAll());
    To copy to clipboard, switch view to plain text mode 
    You get an empty file because there is no more data to read after the first call to readAll().

  3. #3
    Join Date
    Aug 2012
    Posts
    19
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Downloading file problem

    Generally situation looks like this:
    void UpdateMgr:nDownloadingFinished( QNetworkReply* reply )
    {
    if( reply->error() == QNetworkReply::NoError )
    {
    qDebug() << "Size of downloaded file:" << reply->size();
    qDebug() << "Size of saved file:" << reply->readAll().length();
    }
    }

    Size of downloaded file: 11902976
    Size of saved file: 11894784

    Why????

Similar Threads

  1. Proper file downloading?
    By matt4682 in forum Newbie
    Replies: 4
    Last Post: 2nd May 2014, 10:45
  2. Replies: 1
    Last Post: 27th July 2013, 22:57
  3. Concurrent file downloading
    By Alir3z4 in forum Qt Programming
    Replies: 14
    Last Post: 21st February 2012, 15:56
  4. downloading the file problems
    By migel in forum Newbie
    Replies: 0
    Last Post: 7th June 2011, 17:30
  5. File size of a remote file without downloading it
    By dirkdepauw in forum Qt Programming
    Replies: 5
    Last Post: 4th November 2010, 09:48

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.