WebEngineAction QML Type

Eine Aktion, die eine WebEngineView::WebAction darstellt. Mehr...

Import Statement: import QtWebEngine
Since: QtWebEngine 1.8

Eigenschaften

Methoden

Ausführliche Beschreibung

Eine WebEngineAction wird von der Methode WebEngineView::action() zurückgegeben. Sie liefert Informationen über die Aktion, z. B. ob sie enabled ist.

Der folgende Code verwendet die Methode WebEngineView::action(), um zu prüfen, ob die Kopieraktion aktiviert ist:

var copyAction = webEngineView.action(WebEngineView.Copy);
if (copyAction.enabled)
    console.log("Copy is enabled.");
else
    console.log("Copy is disabled.");

Eine ToolButton kann wie folgt mit einer WebEngineAction verbunden werden:

            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
            }

Ein Kontextmenü könnte wie folgt implementiert werden:

        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();
            }
        }

Eigenschaft Dokumentation

enabled : bool [read-only]

Diese Eigenschaft gibt an, ob die Aktion aktiviert ist.


iconName : string [read-only]

Diese Eigenschaft enthält den Namen des Symbols für die Aktion. Dieser Name kann verwendet werden, um das Symbol aus einem Thema auszuwählen.


text : int [read-only]

Diese Eigenschaft enthält eine textuelle Beschreibung der Aktion.


Dokumentation der Methode

void trigger()

Löst die Aktion aus.


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