WebEngineDownloadItem QML 類型

提供下載的有關信息。 更多...

import 語句: import QtWebEngine 1.8
Since: QtWebEngine 1.1

特性

方法

詳細描述

WebEngineDownloadItem models a download throughout its life cycle, starting with a pending download request and finishing with a completed download. It can be used, for example, to get information about new downloads, to monitor progress, and to pause, resume, and cancel downloads.

通常,下載由網頁上的用戶交互觸發。它是 WebEngineProfile 的職責,通知應用程序有新的下載請求,通過發射 downloadRequested signal together with a newly created WebEngineDownloadItem . The application can then examine this item and decide whether to accept it or not. A signal handler must explicitly call accept() on the item for Qt WebEngine to actually start downloading and writing data to disk. If no signal handler calls accept() , then the download request will be automatically rejected and nothing will be written to disk.

注意: Some properties, like the path under which the file will be saved, can only be changed before calling accept() .

對象生命周期

所有項均保證有效,在發齣期間為 downloadRequested 信號。若 accept() is not 被任何信號處理程序所調用,則項會被刪除 immediately 在信號發齣之後。這意味著應用程序 不必 keep references to rejected download items.

網頁下載

除正常文件下載 (簡單地從網絡檢索一些原生字節並把它們寫入磁盤) 外,Qt WebEngine 還支持保存完整網頁,涉及剖析頁麵的 HTML、下載任何從屬資源及把潛在的一切打包進特殊文件格式 ( savePageFormat )。要檢查下載的是文件還是網頁,使用 isSavePageDownload .

另請參閱 WebEngineProfile , WebEngineProfile::downloadRequested ,和 WebEngineProfile::downloadFinished .

特性文檔編製

id : int

保存下載項的 ID。

[read-only] interruptReason : enumeration

返迴下載為什麼中斷的原因:

常量 描述
WebEngineDownloadItem.NoReason 未知原因或未中斷。
WebEngineDownloadItem.FileFailed 常規文件操作故障。
WebEngineDownloadItem.FileAccessDenied 文件無法在本地寫入,由於訪問限定。
WebEngineDownloadItem.FileNoSpace 目標驅動器空間不足。
WebEngineDownloadItem.FileNameTooLong 目錄或文件名太長。
WebEngineDownloadItem.FileTooLarge 文件大小超過文件係統限製。
WebEngineDownloadItem.FileVirusInfected 文件被病毒感染。
WebEngineDownloadItem.FileTransientError 臨時問題 (例如:文件在使用中、內存不足或一次打開太多文件)。
WebEngineDownloadItem.FileBlocked 文件被阻塞由於本地策略。
WebEngineDownloadItem.FileSecurityCheckFailed 試圖檢查下載失敗的安全性,由於意外原因。
WebEngineDownloadItem.FileTooShort 嘗試尋址超齣文件末尾,當打開文件時 (作為再繼續先前被中斷下載的一部分)。
WebEngineDownloadItem.FileHashMismatch 部分文件不匹配預期哈希。
WebEngineDownloadItem.NetworkFailed 常規網絡故障。
WebEngineDownloadItem.NetworkTimeout 網絡操作已超時。
WebEngineDownloadItem.NetworkDisconnected 網絡連接已被終止。
WebEngineDownloadItem.NetworkServerDown 服務器宕機。
WebEngineDownloadItem.NetworkInvalidRequest 網絡請求無效 (例如:原始或重定嚮 URL 無效,方案不受支持或被策略禁止)。
WebEngineDownloadItem.ServerFailed 常規服務器故障。
WebEngineDownloadItem.ServerBadContent 服務器沒有請求的數據。
WebEngineDownloadItem.ServerUnauthorized 服務器未授權訪問資源。
WebEngineDownloadItem.ServerCertProblem 服務器證書發生問題。
WebEngineDownloadItem.ServerForbidden 訪問被服務器禁止。
WebEngineDownloadItem.ServerUnreachable 意外服務器響應 (可能指示響應服務器,可能不是企圖服務器)。
WebEngineDownloadItem.UserCanceled 用戶取消下載。

This property was introduced in QtWebEngine 1.5.

另請參閱 interruptReasonString .

interruptReasonString : string

返迴人類可讀的中斷下載原因的描述。

This property was introduced in QtWebEngine 1.5.

另請參閱 interruptReason .

[read-only] isFinished : bool

Whether this download is finished (completed, cancelled, or non-resumable interrupted state).

This property was introduced in QtWebEngine 1.6.

[read-only] isPaused : bool

Whether this download is paused.

This property was introduced in QtWebEngine 1.6.

另請參閱 pause and resume .

[read-only] isSavePageDownload : bool

Whether this is a download request for saving a web page or a file.

該特性在 QtWebEngine 1.7 引入。

另請參閱 savePageFormat .

mimeType : string

保存下載的 MIME 類型。

This property was introduced in QtWebEngine 1.2.

path : string

Holds the full target path where data is being downloaded to.

The path includes the file name. The default suggested path is the standard download location and file name is deduced not to overwrite already existing files.

The download path can only be set in the downloadRequested handler before the download is accepted.

另請參閱 WebEngineProfile::downloadRequested() and accept() .

receivedBytes : int

Holds the amount of data in bytes that has been downloaded so far.

savePageFormat : enumeration

描述用於保存網頁的格式。

常量 描述
WebEngineDownloadItem.UnknownSaveFormat 這不是下載完整網頁的請求。
WebEngineDownloadItem.SingleHtmlSaveFormat 頁麵被另存為單 HTML 頁麵。圖像等資源不被保存。
WebEngineDownloadItem.CompleteHtmlSaveFormat 頁麵被另存為完整 HTML 頁麵,例如:目錄包含單 HTML 頁麵和資源。
WebEngineDownloadItem.MimeHtmlSaveFormat 以 MIME HTML 格式,把頁麵另存為完整網頁。

該特性在 QtWebEngine 1.3 引入。

state : enumeration

描述下載的狀態:

常量 描述
WebEngineDownloadItem.DownloadRequested 已請求下載,但尚未被接受。
WebEngineDownloadItem.DownloadInProgress 下載正在進行中。
WebEngineDownloadItem.DownloadCompleted 下載成功完成。
WebEngineDownloadItem.DownloadCancelled 下載被用戶取消。
WebEngineDownloadItem.DownloadInterrupted 下載已被中斷 (由服務器或由於丟失連接)。

totalBytes : int

保存要下載的數據總量 (以字節為單位)。

-1 意味著總尺寸未知。

[read-only] view : WebEngineView

Returns the view the download was requested on. If the download was not triggered by content in a view, nullptr 被返迴。

This property was introduced in QtWebEngine 1.8.

另請參閱 WebEngineView .


方法文檔編製

void accept ()

接受下載請求,將開始下載。

若項在 DownloadRequested 狀態,那麼它將過渡到 DownloadInProgress 狀態,且下載會開始。若項在任何其它狀態,則什麼都不會發生。

另請參閱 state .

void cancel ()

取消下載。

若項在 DownloadInProgress 狀態,那麼它將過渡到 DownloadCancelled 狀態,下載會停止,且部分下載文件會從磁盤被刪除。

若項在 DownloadCompleted 狀態,則什麼都不會發生。若項在任何其它狀態,則它會過渡到 DownloadCancelled 狀態,沒有進一步影響。

另請參閱 state .

void pause ()

暫停下載。

不起作用,若狀態不是 DownloadInProgress 。不改變狀態。

This method was introduced in QtWebEngine 1.6.

另請參閱 resume and isPaused .

void resume ()

Resumes the download if it was paused or interrupted.

不起作用,若狀態不是 DownloadInProgress or DownloadInterrupted 。不改變狀態。

This method was introduced in QtWebEngine 1.6.

另請參閱 pause and isPaused .

版權所有  © 2014-2026 樂數軟件    

工業和信息化部: 粵ICP備14079481號-1