在本页

AuthenticationDialogRequest QML Type

请求提供代理或 HTTP 服务器所需的身份验证凭据。更多

Import Statement: import QtWebEngine
Since: QtWebEngine 1.4

属性

方法

详细说明

AuthenticationDialogRequest 作为WebEngineView::authenticationDialogRequested 信号的参数传递。当需要进行基本 HTTP 或代理身份验证时,就会生成该请求。认证类型可通过type 属性进行检查。

请求的accepted 属性表示该请求是由用户代码处理还是显示默认对话框。如果将accepted 属性设置为true ,请确保随后调用dialogAccept() 或dialogReject() 。

以下代码使用自定义对话框处理请求:

WebEngineView {
    // ...
    onAuthenticationDialogRequested: function(request) {
        request.accepted = true;
        myDialog.request = request // keep the reference to the request
        myDialog.accept.connect(request.dialogAccept);
        myDialog.reject.connect(request.dialogReject);
        myDialog.visible = true;
    }
    // ...
}

属性文档

accepted : bool

表示身份验证对话框请求是否已被信号处理程序接受。

如果在执行了WebEngineView::authenticationDialogRequested 的任何信号处理程序后将该属性设置为false ,则将显示默认身份验证对话框。为防止出现这种情况,请将request.accepted 设置为true

默认值为false

proxyHost : string [read-only]

身份验证代理的主机名。如果type 为 AuthenticationTypeHTTP,则为空。

realm : string [read-only]

WWW-Authenticate 标头的 HTTP 身份验证域属性值。如果type 是 AuthenticationTypeProxy,则为空。

type : enumeration [read-only]

身份验证请求的类型。

常量描述
WebEngineAuthenticationDialogRequest.AuthenticationTypeHTTPHTTP 身份验证。
WebEngineAuthenticationDialogRequest.AuthenticationTypeProxy代理身份验证。

url : url [read-only]

请求进行身份验证的 HTTP 请求的 URL。在代理身份验证的情况下,这是通过主机代理的请求 URL。

另请参阅 proxyHost

方法文档

void dialogAccept(string username, string password)

此函数通知引擎用户接受了对话框,并提供username 和身份验证所需的password

void dialogReject()

该函数会通知引擎用户拒绝对话,因此身份验证不会继续。

© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.