QNetworkAccessManager downloading multiple files



  • 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?



  • 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 ?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.