Straightforward, reusable HTTP/HTTPS downloader with retry support. More...
| Header: | #include <QWebDownload> |
| void | error(const QUrl &url, const QString &errorString) |
| void | finished(const QUrl &url, const QByteArray &data) |
| void | finishedWithResult(WebDownloadResult result) |
| void | progress(const QUrl &url, qint64 bytesReceived, qint64 bytesTotal) |
| void | retrying(int attemptNumber, int delayMs) |
QWebDownload performs a single HTTP GET request with support for:
QWebDownload downloader; connect(&downloader, &QWebDownload::finished, this, [](const QUrl& url, const QByteArray& data) { qDebug() << "Downloaded" << data.size() << "bytes from" << url; }); connect(&downloader, &QWebDownload::error, this, [](const QUrl& url, const QString& err) { qWarning() << "Failed:" << url << err; }); downloader.get(QUrl("https://example.com/data.json"));
WebDownloadConfig config; config.retryPolicy = WebRetryPolicy::forCritical(); QWebDownload downloader(config); downloader.get(QUrl("https://example.com/important"));
See also WebDownloadConfig, WebDownloadResult, WebRetryPolicy, and QBatchWebDownload.
[slot] void QWebDownload::abort()Cancels the current download. No signal will fire.
[signal] void QWebDownload::error(const QUrl &url, const QString &errorString)Signals an error. \param url The URL that failed \param errorString Description of the error
[signal] void QWebDownload::finished(const QUrl &url, const QByteArray &data)Signals completion of a download. \param url The final URL (may have changed due to redirects) \param data The downloaded content
[signal] void QWebDownload::finishedWithResult(WebDownloadResult result)Signals completion with full result metadata.
[slot] void QWebDownload::get(const QUrl &url)Starts an HTTP GET from a URL. Notes: URL must be absolute. Calling this function if a download is already in progress will cancel that download.
[signal] void QWebDownload::progress(const QUrl &url, qint64 bytesReceived, qint64 bytesTotal)Progress indicator. Note that bytesTotal will be -1 if unknown.
[signal] void QWebDownload::retrying(int attemptNumber, int delayMs)Signals when a retry is scheduled.