Results 1 to 2 of 2

Thread: Qt 5.1 file not downloading from web on first attempt

  1. #1
    Join Date
    Feb 2013
    Posts
    65
    Thanked 1 Time in 1 Post
    Qt products
    Qt5
    Platforms
    Windows

    Default Qt 5.1 file not downloading from web on first attempt

    I have a problem that occurs with Qt 5.1 (Linux Mint 15 32 bit in Virtualbox) that didn't happen with Qt 5.0.2. I have 2 classes that respond to an update button each, to download an updated input file for each class from the web. The first press of either download button returns a 0 byte file, with button any subsequent button presses working fine, while the GUI app is still running. Restart the app and the problem re-occurs. Here's the download procedure I'm using in each of my classes:

    void class1::downloadFile(const QString &url, const QString &aPathInClient)
    {
    QNetworkAccessManager m_NetworkMngr;// = new QNetworkAccessManager(this);
    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());
    file.open(QIODevice::WriteOnly);
    file.write(reply->readAll());
    file.close();

    delete reply;
    }

    Any insight into this problem would be much appreciated. I have a 64 bit Linux Mint 15 virtual machine that I haven't tried it on yet, and also I haven't tried it on my Windows 7 64 bit host, using msvc2012 32bit. Any code change suggestions are welcome. Like I said, everything worked fine with Qt 5.0.2, both Linux virtual machines, and the Windows 7 host. Thanks in advance for any replies.

    Edit: I found out it also happens with Qt 5.0.2
    Last edited by te777; 27th July 2013 at 23:38.

  2. #2
    Join Date
    Oct 2012
    Posts
    132
    Thanks
    10
    Thanked 21 Times in 21 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: Qt 5.1 file not downloading from web on first attempt

    Use [code] tags when posting code next time.

    Any code change suggestions are welcome.
    Check out the HTTP Example project.

Similar Threads

  1. Downloading a file and saving in a path
    By StarRocks in forum Qt Programming
    Replies: 19
    Last Post: 3rd January 2013, 06:43
  2. Concurrent file downloading
    By Alir3z4 in forum Qt Programming
    Replies: 14
    Last Post: 21st February 2012, 15:56
  3. downloading the file problems
    By migel in forum Newbie
    Replies: 0
    Last Post: 7th June 2011, 17:30
  4. Downloading file over https with proxy
    By szraf in forum Qt Programming
    Replies: 0
    Last Post: 5th April 2011, 16:56
  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

Tags for this Thread

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.