QWebEngineDownloadItem 类

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 )

额外继承成员

详细描述

QWebEngineDownloadItem class provides information about a download.

QWebEngineDownloadItem stores the state of a download to be used to manage requested downloads.

成员类型文档编制

enum QWebEngineDownloadItem:: DownloadInterruptReason

描述下载为什么被中断的原因:

常量 描述
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 引入或被修改。

enum QWebEngineDownloadItem:: DownloadState

此枚举描述下载的状态:

常量 描述
QWebEngineDownloadItem::DownloadRequested 0 下载已请求,但尚未接受。
QWebEngineDownloadItem::DownloadInProgress 1 下载正在进行中。
QWebEngineDownloadItem::DownloadCompleted 2 下载成功完成。
QWebEngineDownloadItem::DownloadCancelled 3 下载已被取消。
QWebEngineDownloadItem::DownloadInterrupted 4 下载已被中断 (由服务器或由于丢失连接)。

enum QWebEngineDownloadItem:: DownloadType

描述请求下载的类型。

常量 描述
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 引入或被修改。

enum QWebEngineDownloadItem:: SavePageFormat

此枚举描述用于保存网页的格式。

常量 描述
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 )

此信号被发射,以指示下载请求的进度。

bytesReceived 参数指示接收字节数,而 bytesTotal 指示期望要下载的总字节数。若要下载的文件大小不知道, bytesTotal 会为 0。

另请参阅 totalBytes () 和 receivedBytes ().

[signal] void QWebEngineDownloadItem:: finished ()

This signal is emitted whenever the download finishes.

另请参阅 state () 和 isFinished ().

quint32 QWebEngineDownloadItem:: id () const

返回下载项 ID。

DownloadInterruptReason QWebEngineDownloadItem:: interruptReason () const

返回下载为什么被中断的原因。

该函数在 Qt 5.9 引入。

另请参阅 interruptReasonString ().

QString QWebEngineDownloadItem:: interruptReasonString () const

返回人类可读的中断下载原因的描述。

该函数在 Qt 5.9 引入。

另请参阅 interruptReason ().

bool QWebEngineDownloadItem:: isFinished () const

Returns whether this download is finished (not in progress).

另请参阅 finished () 和 state ().

QString QWebEngineDownloadItem:: mimeType () const

返回下载的 MIME 类型。

该函数在 Qt 5.6 引入。

QString QWebEngineDownloadItem:: path () const

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 ().

qint64 QWebEngineDownloadItem:: receivedBytes () const

返回到目前为止已下载的数据数量 (以字节为单位)。

-1 意味着尺寸未知。

SavePageFormat QWebEngineDownloadItem:: savePageFormat () const

返回保存网页的格式,如果这是用于网页的下载请求。

该函数在 Qt 5.7 引入。

另请参阅 setSavePageFormat ().

void QWebEngineDownloadItem:: setPath ( QString path )

Sets the full target path to download the file to.

path should also include the file name. The download path can only be set in response to the QWebEngineProfile::downloadRequested () 信号,在下载被接受之前。此后,此函数对下载项的状态没有影响。

另请参阅 path ().

void QWebEngineDownloadItem:: setSavePageFormat ( SavePageFormat format )

设置 format 为网页保存,若这是网页下载请求。

该函数在 Qt 5.7 引入。

另请参阅 savePageFormat ().

DownloadState QWebEngineDownloadItem:: state () const

返回下载项的当前状态。

另请参阅 DownloadState .

[signal] void QWebEngineDownloadItem:: stateChanged ( QWebEngineDownloadItem::DownloadState state )

此信号被发射每当下载的 state 改变。

另请参阅 state () 和 DownloadState .

qint64 QWebEngineDownloadItem:: totalBytes () const

返回要下载的数据总数量 (以字节为单位)。

-1 意味着尺寸未知。

DownloadType QWebEngineDownloadItem:: type () const

Returns the requested download's type.

该函数在 Qt 5.8 引入。

QUrl QWebEngineDownloadItem:: url () const

返回下载的原始 URL。