提供下載的有關信息。 更多...
| import 語句: |
import QtWebEngine
|
| 在 C++: | QWebEngineDownloadRequest |
WebEngineDownloadRequest 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 WebEngineDownloadRequest. The application can then examine this item and decide whether to accept it or not. A signal handler must explicitly call accept () 在項,以便 Qt WebEngine 實際開始下載並把數據寫入磁盤。若沒有信號處理程序調用 accept (),那麼下載請求將被自動拒絕,且什麼都不會被寫入磁盤。
注意: Some properties, like the path under which the file will be saved, can only be changed before calling accept ().
所有項均保證有效,在發齣期間為 downloadRequested 信號。若 accept () 是 not 被任何信號處理程序所調用,則項會被刪除 immediately 在信號發齣之後。這意味著應用程序 不必 keep references to rejected download items.
除正常文件下載 (簡單地從網絡檢索一些原生字節並把它們寫入磁盤) 外,Qt WebEngine 還支持保存完整網頁,涉及剖析頁麵的 HTML、下載任何從屬資源及把潛在的一切打包進特殊文件格式 ( savePageFormat )。要檢查下載的是文件還是網頁,使用 isSavePageDownload .
另請參閱 WebEngineProfile , WebEngineProfile::downloadRequested ,和 WebEngineProfile::downloadFinished .
|
downloadDirectory : string |
Holds the full target path without file name where data is being downloaded to.
The download directory can only be set in the downloadRequested handler before the download is accepted.
另請參閱 WebEngineProfile::downloadRequested () 和 accept ().
|
downloadFileName : string |
Holds the name of the file to which data is being downloaded.
The download file name can only be set in the downloadRequested handler before the download is accepted.
另請參閱 WebEngineProfile::downloadRequested () 和 accept ().
|
id
:
int
|
保存下載項的 ID。
|
interruptReason
:
enumeration
|
返迴下載為什麼中斷的原因:
| 常量 | 描述 |
|---|---|
WebEngineDownloadRequest.NoReason
|
未知原因或未中斷。 |
WebEngineDownloadRequest.FileFailed
|
常規文件操作故障。 |
WebEngineDownloadRequest.FileAccessDenied
|
文件無法在本地寫入,由於訪問限定。 |
WebEngineDownloadRequest.FileNoSpace
|
目標驅動器空間不足。 |
WebEngineDownloadRequest.FileNameTooLong
|
目錄或文件名太長。 |
WebEngineDownloadRequest.FileTooLarge
|
文件大小超過文件係統限製。 |
WebEngineDownloadRequest.FileVirusInfected
|
文件被病毒感染。 |
WebEngineDownloadRequest.FileTransientError
|
臨時問題 (例如:文件在使用中、內存不足或一次打開太多文件)。 |
WebEngineDownloadRequest.FileBlocked
|
文件被阻塞由於本地策略。 |
WebEngineDownloadRequest.FileSecurityCheckFailed
|
試圖檢查下載失敗的安全性,由於意外原因。 |
WebEngineDownloadRequest.FileTooShort
|
嘗試尋址超齣文件末尾,當打開文件時 (作為再繼續先前被中斷下載的一部分)。 |
WebEngineDownloadRequest.FileHashMismatch
|
部分文件不匹配預期哈希。 |
WebEngineDownloadRequest.NetworkFailed
|
常規網絡故障。 |
WebEngineDownloadRequest.NetworkTimeout
|
網絡操作已超時。 |
WebEngineDownloadRequest.NetworkDisconnected
|
網絡連接已被終止。 |
WebEngineDownloadRequest.NetworkServerDown
|
服務器宕機。 |
WebEngineDownloadRequest.NetworkInvalidRequest
|
網絡請求無效 (例如:原始或重定嚮 URL 無效,方案不受支持或被策略禁止)。 |
WebEngineDownloadRequest.ServerFailed
|
常規服務器故障。 |
WebEngineDownloadRequest.ServerBadContent
|
服務器沒有請求的數據。 |
WebEngineDownloadRequest.ServerUnauthorized
|
服務器未授權訪問資源。 |
WebEngineDownloadRequest.ServerCertProblem
|
服務器證書發生問題。 |
WebEngineDownloadRequest.ServerForbidden
|
訪問被服務器禁止。 |
WebEngineDownloadRequest.ServerUnreachable
|
意外服務器響應 (可能指示響應服務器,可能不是企圖服務器)。 |
WebEngineDownloadRequest.UserCanceled
|
用戶取消下載。 |
另請參閱 interruptReasonString .
|
interruptReasonString
:
string
|
返迴人類可讀的中斷下載原因的描述。
另請參閱 interruptReason .
|
isFinished
:
bool
|
Whether this download is finished (completed, cancelled, or non-resumable interrupted state).
|
isPaused
:
bool
|
Whether this download is paused.
|
isSavePageDownload
:
bool
|
Whether this is a download request for saving a web page or a file.
另請參閱 savePageFormat .
|
mimeType
:
string
|
保存下載的 MIME 類型。
|
receivedBytes
:
int
|
Holds the amount of data in bytes that has been downloaded so far.
|
savePageFormat : enumeration |
描述用於保存網頁的格式。
| 常量 | 描述 |
|---|---|
WebEngineDownloadRequest.UnknownSaveFormat
|
這不是下載完整網頁的請求。 |
WebEngineDownloadRequest.SingleHtmlSaveFormat
|
頁麵被另存為單 HTML 頁麵。圖像等資源不被保存。 |
WebEngineDownloadRequest.CompleteHtmlSaveFormat
|
頁麵被另存為完整 HTML 頁麵,例如:目錄包含單 HTML 頁麵和資源。 |
WebEngineDownloadRequest.MimeHtmlSaveFormat
|
以 MIME HTML 格式,把頁麵另存為完整網頁。 |
|
state
:
enumeration
|
描述下載的狀態:
| 常量 | 描述 |
|---|---|
WebEngineDownloadRequest.DownloadRequested
|
已請求下載,但尚未被接受。 |
WebEngineDownloadRequest.DownloadInProgress
|
下載正在進行中。 |
WebEngineDownloadRequest.DownloadCompleted
|
下載成功完成。 |
WebEngineDownloadRequest.DownloadCancelled
|
下載被用戶取消。 |
WebEngineDownloadRequest.DownloadInterrupted
|
下載已被中斷 (由服務器或由於丟失連接)。 |
|
suggestedFileName
:
string
|
返迴建議的文件名。
|
totalBytes
:
int
|
保存要下載的數據總量 (以字節為單位)。
-1
意味著總尺寸未知。
|
url
:
url
|
返迴下載的原始 URL。
|
view
:
WebEngineView
|
Returns the view the download was requested on. If the download was not triggered by content in a view,
nullptr
被返迴。
另請參閱 WebEngineView .
|
void accept () |
接受下載請求,將開始下載。
若項在
DownloadRequested
狀態,那麼它將過渡到
DownloadInProgress
狀態,且下載會開始。若項在任何其它狀態,則什麼都不會發生。
另請參閱 state .
|
void cancel () |
取消下載。
若項在
DownloadInProgress
狀態,那麼它將過渡到
DownloadCancelled
狀態,下載會停止,且部分下載文件會從磁盤被刪除。
若項在
DownloadCompleted
狀態,則什麼都不會發生。若項在任何其它狀態,則它會過渡到
DownloadCancelled
狀態,沒有進一步影響。
另請參閱 state .
|
void pause () |
暫停下載。
不起作用,若狀態不是
DownloadInProgress
。不改變狀態。
|
void resume () |
Resumes the download if it was paused or interrupted.
不起作用,若狀態不是
DownloadInProgress
or
DownloadInterrupted
。不改變狀態。