TooltipRequest QML Type

向用户显示工具提示的请求。更多

Import Statement: import QtWebEngine
Since: QtWebEngine 1.10

属性

详细说明

TooltipRequest 是一个请求对象,作为WebEngineView::tooltipRequested 信号的参数传递。使用onTooltipRequested 信号处理器可在特定位置处理自定义工具提示菜单请求。

请求的accepted 属性表示该请求是由用户代码处理还是显示默认工具提示。

以下代码使用自定义工具提示来处理请求:

WebEngineView {
    // ...
    onTooltipRequested: function(request) {
        if (request.type == TooltipRequest.Show) {
            tooltip.visible = true;
            tooltip.x = request.x;
            tooltip.y = request.y;
            tooltip.text = request.text;
        } else {
            tooltip.visible = false;
        }
        request.accepted = true;
    }
    // ...
}

属性文档

accepted : bool

表示工具提示请求是否已被信号处理程序接受。

如果在WebEngineView::tooltipRequested 的任何信号处理程序执行后,属性false ,则将显示默认工具提示。为防止出现这种情况,请将request.accepted 设置为true

默认值为false


text : bool [read-only]

工具提示文本。当工具提示应该隐藏时,它包含一个空字符串。


type : enumeration [read-only]

工具提示请求的类型。

常量说明
TooltipRequest.Show应显示的工具提示。
TooltipRequest.Hide应隐藏的工具提示。

x : int [read-only]

请求的工具提示左上角的 x 坐标。


y : int [read-only]

工具提示左上角的 y 坐标。


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