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

ActionGroup QML Type

Groups actions together.

Article lu   fois.

L'auteur

Liens sociaux

Viadeo Twitter Facebook Share on Google+   

ActionGroup QML Type

  • Import Statement: import QtQuick.Controls

  • Inherits: QtObject

  • Group: ActionGroup is part of utilities

Detailed Description

ActionGroup is a non-visual group of actions. A mutually exclusive action group is used with actions where only one of the options can be selected at a time.

The most straight-forward way to use ActionGroup is to declare actions as children of the group.

 
Sélectionnez
ActionGroup {
    id: alignmentGroup

    Action {
        checked: true
        checkable: true
        text: qsTr("Left")
    }

    Action {
        checkable: true
        text: qsTr("Center")
    }

    Action {
        checkable: true
        text: qsTr("Right")
    }
}

Alternatively, the group attached property allows declaring the actions elsewhere and assigning them to a specific group.

 
Sélectionnez
ActionGroup { id: alignmentGroup }

Action {
    checked: true
    checkable: true
    text: qsTr("Left")
    ActionGroup.group: alignmentGroup
}

Action {
    checkable: true
    text: qsTr("Center")
    ActionGroup.group: alignmentGroup
}

Action {
    checkable: true
    text: qsTr("Right")
    ActionGroup.group: alignmentGroup
}

More advanced use cases can be handled using the addAction() and removeAction() methods.

See Also

See also Action, ButtonGroup

Property Documentation

 

[default] actions : list<Action>

This property holds the list of actions in the group.

See Also

See also group

checkedAction : Action

This property holds the currently selected action in an exclusive group, or null if there is none or the group is non-exclusive.

By default, it is the first checked action added to an exclusive action group.

See Also

See also exclusive

enabled : bool

This property holds whether the action group is enabled. The default value is true.

If this property is false, then all actions in the group are disabled. If this property is true, all actions in the group are enabled, unless explicitly disabled.

exclusive : bool

This property holds whether the action group is exclusive. The default value is true.

If this property is true, then only one action in the group can be checked at any given time. The user can trigger any action to check it, and that action will replace the existing one as the checked action in the group.

In an exclusive group, the user cannot uncheck the currently checked action by triggering it; instead, another action in the group must be triggered to set the new checked action for that group.

In a non-exclusive group, checking and unchecking actions does not affect the other actions in the group. Furthermore, the value of the checkedAction property is null.

Attached Property Documentation

 

ActionGroup.group : ActionGroup

This property attaches an action to an action group.

 
Sélectionnez
ActionGroup { id: group }

Action {
    checked: true
    text: qsTr("Option A")
    ActionGroup.group: group
}

Action {
    text: qsTr("Option B")
    ActionGroup.group: group
}
See Also

See also actions

Signal Documentation

 

triggered(Action action)

This signal is emitted when an action in the group has been triggered.

This signal is convenient for implementing a common signal handler for all actions in the same group.

 
Sélectionnez
ActionGroup {
    onTriggered: console.log("triggered:", action.text)

    Action { text: "First" }
    Action { text: "Second" }
    Action { text: "Third" }
}

The corresponding handler is onTriggered.

See Also

See also Action::triggered()

Method Documentation

 

void addAction(Action action)

Adds an action to the action group.

Manually adding objects to a action group is typically unnecessary. The actions property and the group attached property provide a convenient and declarative syntax.

See Also

See also actions, group

void removeAction(Action action)

Removes an action from the action group.

Manually removing objects from a action group is typically unnecessary. The actions property and the group attached property provide a convenient and declarative syntax.

See Also

See also actions, group

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