IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)

WebEngineAction QML Type

An action that represents a WebEngineView::WebAction.

This type was introduced in QtWebEngine 1.8.

Article lu   fois.

L'auteur

Liens sociaux

Viadeo Twitter Facebook Share on Google+   

WebEngineAction QML Type

  • Import Statement: import QtWebEngine

  • Since: QtWebEngine 1.8

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:

 
Sélectionnez
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:

 
Sélectionnez
            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
            }

A context menu could be implemented like this:

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

Property Documentation

 

[read-only] enabled : bool

This property holds whether the action is enabled.

[read-only] iconName : string

This property holds the name of the icon for the action. This name can be used to pick the icon from a theme.

[read-only] text : int

This property holds a textual description of the action.

Method Documentation

 

void trigger()

Triggers the action.

Vous avez aimé ce tutoriel ? Alors partagez-le en cliquant sur les boutons suivants : Viadeo Twitter Facebook Share on Google+