StateGroup QML Type

Provides built-in state support for non-Item types. More...

Import Statement: import QtQuick 2.12

Properties

Detailed Description

Item (and all derived types) provides built in support for states and transitions via its state, states and transitions properties. StateGroup provides an easy way to use this support in other (non-Item-derived) types.

MyCustomObject {
    StateGroup {
        id: myStateGroup
        states: State {
            name: "state1"
            // ...
        }
        transitions: Transition {
            // ...
        }
    }

    onSomethingHappened: myStateGroup.state = "state1";
}

See also Qt Quick States, Transitions, and Qt QML.

Property Documentation

state : string

This property holds the name of the current state of the state group.

This property is often used in scripts to change between states. For example:

function toggle() {
    if (button.state == 'On')
        button.state = 'Off';
    else
        button.state = 'On';
}

If the state group is in its base state (i.e. no explicit state has been set), state will be a blank string. Likewise, you can return a state group to its base state by setting its current state to ''.

See also Qt Quick States.


states : list<State>

This property holds a list of states defined by the state group.

StateGroup {
    states: [
        State {
            // State definition...
        },
        State {
            // ...
        }
        // Other states...
    ]
}

See also Qt Quick States.


transitions : list<Transition>

This property holds a list of transitions defined by the state group.

StateGroup {
    transitions: [
        Transition {
          // ...
        },
        Transition {
          // ...
        }
        // ...
    ]
}

See also Transitions.


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