WebEngineAction QML Type
代表WebEngineView::WebAction... 更多...
Import Statement: | import QtWebEngine |
Since: | QtWebEngine 1.8 |
属性
方法
- void trigger()
详细说明
WebEngineAction 由WebEngineView::action() 方法返回。它提供有关该操作的信息,如是否enabled 。
以下代码使用WebEngineView::action() 方法检查复制操作是否启用:
var copyAction = webEngineView.action(WebEngineView.Copy); if (copyAction.enabled) console.log("Copy is enabled."); else console.log("Copy is disabled.");
ToolButton 与 WebEngineAction 的连接方式如下:
ToolButton { property int itemAction: WebEngineView.Back text: webEngineView.action(itemAction).text enabled: webEngineView.action(itemAction).enabled onClicked: webEngineView.action(itemAction).trigger() icon.name: webEngineView.action(itemAction).iconName display: AbstractButton.TextUnderIcon }
上下文菜单可以这样实现:
property Menu contextMenu: Menu { Repeater { model: [ WebEngineView.Back, WebEngineView.Forward, WebEngineView.Reload, WebEngineView.SavePage, WebEngineView.Copy, WebEngineView.Paste, WebEngineView.Cut, WebEngineView.ChangeTextDirectionLTR, WebEngineView.ChangeTextDirectionRTL, ] MenuItem { text: webEngineView.action(modelData).text enabled: webEngineView.action(modelData).enabled onClicked: webEngineView.action(modelData).trigger() icon.name: webEngineView.action(modelData).iconName display: MenuItem.TextBesideIcon } } } onContextMenuRequested: function(request) { if (customContextMenuOption.checked) { request.accepted = true; contextMenu.popup(); } }
属性文档
enabled : bool |
该属性表示动作是否启用。
iconName : string |
该属性包含动作图标的名称。该名称可用于从主题中选择图标。
text : int |
该属性包含动作的文字描述。
方法文档
void trigger() |
触发操作。
© 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.