The QWebEngineDownloadItem class provides information about a download. 更多...
| 頭: | #include <QWebEngineDownloadItem> |
| qmake: | QT += webenginewidgets |
| Since: | Qt 5.5 |
| 繼承: | QObject |
| enum | DownloadInterruptReason { NoReason, FileFailed, FileAccessDenied, FileNoSpace, ..., UserCanceled } |
| enum | DownloadState { DownloadRequested, DownloadInProgress, DownloadCompleted, DownloadCancelled, DownloadInterrupted } |
| enum | DownloadType { Attachment, DownloadAttribute, UserRequested, SavePage } |
| enum | SavePageFormat { UnknownSaveFormat, SingleHtmlSaveFormat, CompleteHtmlSaveFormat, MimeHtmlSaveFormat } |
| quint32 | id () const |
| DownloadInterruptReason | interruptReason () const |
| QString | interruptReasonString () const |
| bool | isFinished () const |
| QString | mimeType () const |
| QString | path () const |
| qint64 | receivedBytes () const |
| SavePageFormat | savePageFormat () const |
| void | setPath (QString path ) |
| void | setSavePageFormat (SavePageFormat format ) |
| DownloadState | state () const |
| qint64 | totalBytes () const |
| DownloadType | type () const |
| QUrl | url () const |
| void | accept () |
| void | cancel () |
| void | downloadProgress (qint64 bytesReceived , qint64 bytesTotal ) |
| void | finished () |
| void | stateChanged (QWebEngineDownloadItem::DownloadState state ) |
The QWebEngineDownloadItem class provides information about a download.
QWebEngineDownloadItem stores the state of a download to be used to manage requested downloads.
描述下載為什麼被中斷的原因:
| 常量 | 值 | 描述 |
|---|---|---|
QWebEngineDownloadItem::NoReason
|
0
|
未知原因或未中斷。 |
QWebEngineDownloadItem::FileFailed
|
1
|
常規文件操作故障。 |
QWebEngineDownloadItem::FileAccessDenied
|
2
|
文件無法在本地寫入,由於訪問限定。 |
QWebEngineDownloadItem::FileNoSpace
|
3
|
目標驅動器空間不足。 |
QWebEngineDownloadItem::FileNameTooLong
|
5
|
目錄或文件名太長。 |
QWebEngineDownloadItem::FileTooLarge
|
6
|
文件大小超過文件係統限製。 |
QWebEngineDownloadItem::FileVirusInfected
|
7
|
文件被病毒感染。 |
QWebEngineDownloadItem::FileTransientError
|
10
|
臨時問題 (例如:文件在使用中、內存不足或一次打開太多文件)。 |
QWebEngineDownloadItem::FileBlocked
|
11
|
文件被阻塞由於本地策略。 |
QWebEngineDownloadItem::FileSecurityCheckFailed
|
12
|
試圖檢查下載失敗的安全性,由於意外原因。 |
QWebEngineDownloadItem::FileTooShort
|
13
|
嘗試尋址超齣文件末尾,當打開文件時 (作為再繼續先前被中斷下載的一部分)。 |
QWebEngineDownloadItem::FileHashMismatch
|
14
|
部分文件不匹配預期哈希。 |
QWebEngineDownloadItem::NetworkFailed
|
20
|
常規網絡故障。 |
QWebEngineDownloadItem::NetworkTimeout
|
21
|
網絡操作已超時。 |
QWebEngineDownloadItem::NetworkDisconnected
|
22
|
網絡連接已被終止。 |
QWebEngineDownloadItem::NetworkServerDown
|
23
|
服務器宕機。 |
QWebEngineDownloadItem::NetworkInvalidRequest
|
24
|
網絡請求無效 (例如:原始或重定嚮 URL 無效,方案不受支持或被策略禁止)。 |
QWebEngineDownloadItem::ServerFailed
|
30
|
常規服務器故障。 |
QWebEngineDownloadItem::ServerBadContent
|
33
|
服務器沒有請求的數據。 |
QWebEngineDownloadItem::ServerUnauthorized
|
34
|
服務器未授權訪問資源。 |
QWebEngineDownloadItem::ServerCertProblem
|
35
|
服務器證書發生問題。 |
QWebEngineDownloadItem::ServerForbidden
|
36
|
訪問被服務器禁止。 |
QWebEngineDownloadItem::ServerUnreachable
|
37
|
意外服務器響應 (可能指示響應服務器,可能不是企圖服務器)。 |
QWebEngineDownloadItem::UserCanceled
|
40
|
用戶取消下載。 |
該枚舉在 Qt 5.9 引入或被修改。
此枚舉描述下載的狀態:
| 常量 | 值 | 描述 |
|---|---|---|
QWebEngineDownloadItem::DownloadRequested
|
0
|
下載已請求,但尚未接受。 |
QWebEngineDownloadItem::DownloadInProgress
|
1
|
下載正在進行中。 |
QWebEngineDownloadItem::DownloadCompleted
|
2
|
下載成功完成。 |
QWebEngineDownloadItem::DownloadCancelled
|
3
|
下載已被取消。 |
QWebEngineDownloadItem::DownloadInterrupted
|
4
|
下載已被中斷 (由服務器或由於丟失連接)。 |
描述請求下載的類型。
| 常量 | 值 | 描述 |
|---|---|---|
QWebEngineDownloadItem::Attachment
|
0
|
Web 服務器的響應包括
Content-Disposition
頭具有
attachment
指令。若
Content-Disposition
存在於迴復中,Web 服務器指示客戶端應該提示用戶保存內容,不管內容類型。見
RFC 2616 第 19.5.1 節
瞭解細節。
|
QWebEngineDownloadItem::DownloadAttribute
|
1
|
用戶點擊的鏈接具有
download
屬性。見
HTML 下載屬性
瞭解細節。
|
QWebEngineDownloadItem::UserRequested
|
2
|
用戶初啓下載,例如通過選擇 Web 操作。 |
QWebEngineDownloadItem::SavePage
|
3
|
請求保存當前頁麵 (例如通過 QWebEnginePage::SavePage Web 動作)。 |
該枚舉在 Qt 5.8 引入或被修改。
此枚舉描述用於保存網頁的格式。
| 常量 | 值 | 描述 |
|---|---|---|
QWebEngineDownloadItem::UnknownSaveFormat
|
-1
|
這不是下載完整網頁的請求。 |
QWebEngineDownloadItem::SingleHtmlSaveFormat
|
0
|
頁麵被另存為單 HTML 頁麵。圖像等資源不被保存。 |
QWebEngineDownloadItem::CompleteHtmlSaveFormat
|
1
|
頁麵被另存為完整 HTML 頁麵,例如:目錄包含單 HTML 頁麵和資源。 |
QWebEngineDownloadItem::MimeHtmlSaveFormat
|
2
|
以 MIME HTML 格式,把頁麵另存為完整網頁。 |
該枚舉在 Qt 5.7 引入或被修改。
[slot]
void
QWebEngineDownloadItem::
accept
()
接受當前下載請求,將開始下載。
另請參閱 finished () 和 stateChanged ().
[slot]
void
QWebEngineDownloadItem::
cancel
()
取消當前下載。
另請參閱 finished () 和 stateChanged ().
[signal]
void
QWebEngineDownloadItem::
downloadProgress
(
qint64
bytesReceived
,
qint64
bytesTotal
)
此信號被發射,以指示下載請求的進度。
The
bytesReceived
參數指示接收字節數,而
bytesTotal
指示期望要下載的總字節數。若要下載的文件大小不知道,
bytesTotal
會為 0。
另請參閱 totalBytes () 和 receivedBytes ().
[signal]
void
QWebEngineDownloadItem::
finished
()
This signal is emitted whenever the download finishes.
另請參閱 state () 和 isFinished ().
返迴下載項 ID。
返迴下載為什麼被中斷的原因。
該函數在 Qt 5.9 引入。
另請參閱 interruptReasonString ().
返迴人類可讀的中斷下載原因的描述。
該函數在 Qt 5.9 引入。
另請參閱 interruptReason ().
Returns whether this download is finished (not in progress).
返迴下載的 MIME 類型。
該函數在 Qt 5.6 引入。
Returns 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.
另請參閱 setPath ().
返迴到目前為止已下載的數據數量 (以字節為單位)。
-1
意味著尺寸未知。
返迴保存網頁的格式,若這是針對網頁的下載請求。
該函數在 Qt 5.7 引入。
另請參閱 setSavePageFormat ().
Sets the full target path to download the file to.
The path should also include the file name. The download path can only be set in response to the QWebEngineProfile::downloadRequested () 信號在接受下載前。此後,此函數對下載項狀態不起作用。
另請參閱 path ().
設置 format 為網頁保存,若這是網頁下載請求。
該函數在 Qt 5.7 引入。
另請參閱 savePageFormat ().
返迴下載項的當前狀態。
另請參閱 DownloadState .
[signal]
void
QWebEngineDownloadItem::
stateChanged
(
QWebEngineDownloadItem::DownloadState
state
)
此信號發射每當下載的 state 改變。
另請參閱 state () 和 DownloadState .
返迴要下載的數據總數量 (以字節為單位)。
-1
意味著尺寸未知。
Returns the requested download's type.
該函數在 Qt 5.8 引入。
返迴下載的原始 URL。