while(i != sp.count()) { file.setFileName("files/"+sp.value(i)); file.open(QIODevice::WriteOnly); request.setUrl(QUrl("http://192.168.1.223/farma/zagruz/"+sp.value(i))); manager.moveToThread(QApplication::instance()->thread()); reply = manager.get(request); //Отправляем запрос reply->moveToThread(QApplication::instance()->thread()); connect(&manager, SIGNAL(finished(QNetworkReply*)),this, SLOT(replyFinished(QNetworkReply*))); connect(reply,SIGNAL(readyRead()),this,SLOT(readyRead())); i++; }
void nomkl_num::readyRead(){ file.setFileName("files/"+sp.value(zakaz)); file.open(QIODevice::WriteOnly); file.write(reply->readAll()); zakaz++;}
void nomkl_num::send_save_file(){ request.setUrl(QUrl("http://192.168.1.223/farma/zagruz/"+sp.value(zakaz))); manager.moveToThread(QApplication::instance()->thread()); reply = manager.get(request); //Отправляем запрос reply->moveToThread(QApplication::instance()->thread()); connect(reply,SIGNAL(readyRead()),this,SLOT(readyRead())); connect(&manager, SIGNAL(finished(QNetworkReply*)),this, SLOT(replyFinished(QNetworkReply*)));}void nomkl_num::readyRead(){ QStringList sl; sl = reply->url().path().split("/"); file.setFileName("files/"+sl.value(3)); file.open(QIODevice::WriteOnly); file.write(reply->readAll()); }void nomkl_num::replyFinished(QNetworkReply *){ if (reply->error()) { QMessageBox::information(this,tr("error download"),reply->errorString(),QMessageBox::Ok); } else { //QMessageBox::information(this,tr("Сообщение"),tr("Загрузка завершена успешно"),QMessageBox::Ok); qDebug() << "download complete"; file.close(); zakaz++; send_save_file(); }}
QStringList sl; sl = reply->url().path().split("/"); file.setFileName("files/"+sl.value(3)); file.open(QIODevice::WriteOnly); file.write(reply->readAll()); file.close(); sl.clear(); zakaz++; kol++; send_save_file(); if (kol == sp.count()) { load(); }