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. QNetworkAccessManager downloading multiple files
Qt 6.11 is out! See what's new in the release blog

QNetworkAccessManager downloading multiple files

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 1.3k Views 2 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
    RubberJones
    wrote on last edited by
    #1

    I'm trying to download multiple files with QNetworkAccessManager. Everything works fine until an error occurs.

    example:
    file1 //good
    file2 //good
    file3 //bad, files after file3 will not processed
    file4
    file5

    Download will work perfect if no error occurs.

    QByteArray filename;
    QNetworkRequest myrequest;
    QNetworkReply *myreply = 0;
    
    foreach(QString file, m_downloadFileList) {
            filename = file.toAscii();
            myrequest = ftpRequest(filename);
            myreply = manager->get(myrequest);
            myreply->setObjectName(file);
            connect (myreply, SIGNAL(downloadProgress(qint64,qint64)), this, SLOT(slDownload(qint64, qint64)));
            connect (myreply, SIGNAL(finished()), this, SLOT(slReadCompleted()));
            connect (myreply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(slReplyError(QNetworkReply::NetworkError)));
     }
    

    How to manage error handling, so I can download files after the first error.
    Do I have to delete the manager class every time if an error occurs?

    1 Reply Last reply
    0
    • dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Moderators Qt Champions 2024 Qt Champions 2022 Qt Champions 2017
      wrote on last edited by
      #2

      QNetworkAccessManager should not create issue as it queue the requests. My suspect is on QNetworkRequest object as u r using the same object. Also what that you are doing inside the slot when the error occurs ?

      Dheerendra
      @Community Service
      Certified Qt Specialist
      https://www.pthinks.com

      1 Reply Last reply
      4

      • Login

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