Downloads multiple URLs in parallel by wrapping QWebDownload. More...
| Header: | #include <QBatchWebDownload> |
| QBatchWebDownload(int timeoutMs = 30000, int maxRedirects = 10, QObject *parent = nullptr, QNetworkAccessManager *networkManager = nullptr) | |
| void | abort() |
| void | get(const QList<QUrl> &urls) |
| QMap<QUrl, BatchWebDownloadResult> | results() const |
Use case: You need to download multiple things and wait for all the results before proceeding.
QBatchWebDownload batch; connect(&batch, &QBatchWebDownload::finished, this, [&batch]() { for (auto it = batch.results().constBegin(); it != batch.results().constEnd(); ++it) { if (it.value().success) { qDebug() << it.key() << "->" << it.value().data.size() << "bytes"; } } }); batch.get({QUrl("https://example.com/a"), QUrl("https://example.com/b")});
See also QWebDownload and BatchWebDownloadResult.
[explicit] QBatchWebDownload::QBatchWebDownload(int timeoutMs = 30000, int maxRedirects = 10, QObject *parent = nullptr, QNetworkAccessManager *networkManager = nullptr)\paramtimeoutMs \param maxRedirects \param parent \param networkManager If specified, caller is responsible for its lifecycle.
Abort all pending downloads.
[signal] void QBatchWebDownload::finished()Emitted when all downloads complete (success or failure).
Start downloading a list of URLs, emits finished() when done.
[signal] void QBatchWebDownload::progress(int completed, int total)Emitted as downloads complete to show progress.
\paramcompleted Number of completed downloads \param total Total number of downloads
Get the results (after finished() is emitted.)