QgsFileDownloader class
QgsFileDownloader is a utility class for downloading files.
Contents
To use this class, it is necessary to pass the URL and an output file name as arguments to the constructor, the download will start immediately.
The download is asynchronous.
The object will destroy itself when the request completes, errors or is canceled. An optional authentication configuration can be specified.
Constructors, destructors, conversion operators
- QgsFileDownloader(const QUrl& url, const QString& outputFileName, const QString& authcfg = QString(), bool delayStart = false)
- QgsFileDownloader.
Signals
- void downloadCanceled()
- Emitted when the download was canceled by the user.
- void downloadCompleted()
- Emitted when the download has completed successfully.
- void downloadError(QStringList errorMessages)
- Emitted when an error makes the download fail.
- void downloadExited()
- Emitted always when the downloader exits.
- void downloadProgress(qint64 bytesReceived, qint64 bytesTotal)
- Emitted when data are ready to be processed.
Public slots
- void cancelDownload()
- Call to abort the download and delete this object after the cancelation has been processed.
- void startDownload()
- Called to start the download.
Function documentation
QgsFileDownloader:: QgsFileDownloader(const QUrl& url,
const QString& outputFileName,
const QString& authcfg = QString(),
bool delayStart = false)
| Parameters | |
|---|---|
| url | the download url |
| outputFileName | file name where the downloaded content will be stored |
| authcfg | optionally apply this authentication configuration |
| delayStart | if true, the download will not be commenced immediately and must be triggered by a later call to startDownload(). This can be useful if connections need to be made to the downloader and there's a chance the download will emit signals before these connections have been made. |
void QgsFileDownloader:: downloadCanceled() signal
Emitted when the download was canceled by the user.
void QgsFileDownloader:: cancelDownload() public slot
Call to abort the download and delete this object after the cancelation has been processed.