- Qt 6.9
- Qt Quick
- QML Types
- Qt.labs.assetdownloader
- AssetDownloader
- Qt 6.9.3 Reference Documentation

# AssetDownloader QML Type

Downloads assets asynchronously for use in QML Examples. More...

Import Statement: | `import Qt.labs.assetdownloader`
Since: | Qt 6.8

- List of all members, including inherited members

## Properties

- downloadBase : url
- jsonFileName : string
- localDownloadDir : url
- offlineAssetsFilePath : url
- preferredLocalDownloadDir : url
- zipFileName : string

## Signals

- finished(bool success)
- progressChanged(int progressValue, int progressMaximum, string progressText)
- started()

## Methods

- stringlist networkErrors()
- stringlist sslErrors()
- void start()

## Detailed Description

The AssetDownloader type provides a convenient way to download external assets such as images, models, or data files from remote URLs and make them available to QML applications.

Note: This type is not part of the public Qt API and may change without notice. It is intended for internal use or tightly controlled environments.

## QML Usage

To use this type in QML, import the module and instantiate the downloader:

     import Qt.labs.assetdownloader

     AssetDownloader {
         downloadBase: "https://example.com/assets/"
         preferredLocalDownloadDir: "file:///home/user/assets/"
         jsonFileName: "data.json"
         zipFileName: "archive.zip"
         onFinished: (success) => {
             if (success)
                 console.log("Download completed successfully");
             else
                 console.log("Download failed");
         }
     }

## Property Documentation

downloadBase : url

The base URL from which assets will be downloaded.

jsonFileName : string

The name of the asset JSON file to be downloaded. This file should contain a list of assets to be downloaded.

Example format:

     {
         "url": "<base URL for asset downloads>",
         "assets": [
             "<relative path to asset file>",
             ...
         ]
     }

localDownloadDir : url

The actual local directory where assets are stored after download.

offlineAssetsFilePath : url

The file path to offline assets, used when network access is unavailable.

preferredLocalDownloadDir : url

The preferred local directory where downloaded assets should be stored.

zipFileName : string

The name of the ZIP file to be downloaded.

## Signal Documentation

finished(bool success)

Emitted when the download process finishes. The success parameter indicates whether the download was successful.

Note: The corresponding handler is `onFinished`.

See also AssetDownloader::networkErrors and AssetDownloader::sslErrors.

progressChanged(int progressValue, int progressMaximum, string progressText)

Emitted to indicate progress during the download. progressValue is the current progress, progressMaximum is the total expected progress, and progressText provides a textual description.

Note: The corresponding handler is `onProgressChanged`.

started()

Emitted when the download process starts.

Note: The corresponding handler is `onStarted`.

## Method Documentation

stringlist networkErrors()

Returns a list of network-related errors encountered during the download.

stringlist sslErrors()

Returns a list of SSL-related errors encountered during the download.

void start()

Starts the download process.