AssetDownloader QML Type

Downloads assets asynchronously for use in QML Examples. 更多...

import 语句: import Qt.labs.assetdownloader
Since: Qt 6.8

特性

信号

方法

详细描述

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.

注意: 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");
    }
}
					

特性文档编制

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.

信号文档编制

finished ( bool success )

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

注意: 相应处理程序是 onFinished .

另请参阅 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.

注意: 相应处理程序是 onProgressChanged .

started ()

Emitted when the download process starts.

注意: 相应处理程序是 onStarted .

方法文档编制

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.