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)

此函数通知引擎用户接受了对话框,并提供usernamepassword 认证所需的信息。


void dialogReject()

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


© 2025 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.