WebEngineAction QML Type

WebEngineView::WebAction...続きを読む

Import Statement: import QtWebEngine
Since: QtWebEngine 1.8

プロパティ

方法

詳細説明

WebEngineAction は、WebEngineView::action() メソッドによって返されます。WebEngineAction は、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 [read-only]

このプロパティは、アクションが有効かどうかを保持します。


iconName : string [read-only]

このプロパティは、アクションのアイコンの名前を保持します。この名前を使用して、テーマからアイコンを選ぶことができます。


text : int [read-only]

このプロパティは、アクションのテキストによる説明を保持します。


メソッドの説明

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.