QML StateGroup Element

The StateGroup element provides state support for non-Item elements. More...

This element was introduced in Qt 4.7.

Properties

Detailed Description

Item (and all derived elements) 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) elements.

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

     onSomethingHappened: myStateGroup.state = "state1";
 }

See also States, Transitions, and QtDeclarative.

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


read-onlystates : list<State>

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

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

See also States.


read-onlytransitions : list<Transition>

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

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

See also Transitions.


Notes provided by the Qt Community
Informative
  • 4

Votes: 3

Coverage: Qt library 4.7, 4.8

Picture of Andre Andre

Mad Scientist
21 notes

Nokia Certified Qt Developer

Also works for Items

Even though this documentation states:

The StateGroup element provides state support for non-Item elements.

the StateGroup element can still be used on Item elements to create multiple parallel states. If you only need a single state group however, you should use the state group build into the Item element.

[Revisions]