WebEngineAction QML Type | Qt WebEngine (original) (raw)
An action that represents a WebEngineView::WebAction. More...
Import Statement: | import QtWebEngine |
---|---|
Since: | QtWebEngine 1.8 |
Properties
Methods
- void trigger()
Detailed Description
A WebEngineAction is returned by the WebEngineView::action() method. It provides information about the action, such as whether it is enabled.
The following code uses the WebEngineView::action() method to check if the copy action is enabled:
var copyAction = webEngineView.action(WebEngineView.Copy); if (copyAction.enabled) console.log("Copy is enabled."); else console.log("Copy is disabled.");
A ToolButton can be connected to a WebEngineAction as follows:
[ToolButton](qml-qtquick-controls-toolbutton.html) {
property [int](qml-int.html) 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
}
A context menu could be implemented like this:
property [Menu](qml-qtquick-controls-menu.html) contextMenu: Menu {
[Repeater](qml-qtquick-repeater.html) {
model: [
WebEngineView.Back,
WebEngineView.Forward,
WebEngineView.Reload,
WebEngineView.SavePage,
WebEngineView.Copy,
WebEngineView.Paste,
WebEngineView.Cut,
WebEngineView.ChangeTextDirectionLTR,
WebEngineView.ChangeTextDirectionRTL,
]
[MenuItem](qml-qtquick-controls-menuitem.html) {
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();
}
}
Property Documentation
enabled : bool [read-only]
This property holds whether the action is enabled.
This property holds the name of the icon for the action. This name can be used to pick the icon from a theme.
This property holds a textual description of the action.
Method Documentation
© 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.