ColorDialogRequest QML Type

用户选择颜色的请求。更多

Import Statement: import QtWebEngine
Since: QtWebEngine 1.4

属性

方法

详细说明

ColorDialogRequest 作为WebEngineView::colorDialogRequested 信号的参数传递。它在请求颜色选择器对话框时生成。请参见HTML5 颜色状态

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

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

WebEngineView {
    // ...
    onColorDialogRequested: 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::colorDialogRequested 的任何信号处理程序后,该属性为false ,则将显示默认的取色器对话框。为防止出现这种情况,请将request.accepted 设置为true

默认值为false


color : color [read-only]

在对话框中选择的默认颜色。


方法文档

void dialogAccept(color color)

此函数通知引擎用户接受了对话框,并提供color


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.