In questa pagina

StateGroup QML Type

Fornisce il supporto integrato per lo stato dei tipi diversi da Item. Altro...

Import Statement: import QtQuick

Proprietà

Descrizione dettagliata

La classe Item (e tutti i tipi da essa derivati) fornisce un supporto integrato per gli stati e le transizioni tramite le proprietà state, states e transitions. La classe StateGroup offre un modo semplice per utilizzare questo supporto in altri tipi (non derivati da Item).

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

    onSomethingHappened: myStateGroup.state = "state1";
}

Vedi anche Qt Quick Stati, transizioni e Qt Qml.

Documentazione sulle proprietà

state : string

Questa proprietà contiene il nome dello stato corrente del gruppo di stati.

Questa proprietà viene spesso utilizzata negli script per passare da uno stato all'altro. Ad esempio:

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

Se il gruppo di stati si trova nel suo stato di base (ovvero non è stato impostato alcuno stato esplicito), state sarà una stringa vuota. Allo stesso modo, è possibile riportare un gruppo di stati al suo stato di base impostando il suo stato corrente su ''.

Vedi anche Stati diQt Quick .

states : list<State> [read-only]

Questa proprietà contiene un elenco di stati definiti dal gruppo di stati.

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

Vedi anche Stati dell'Qt Quick .

transitions : list<Transition> [read-only]

Questa proprietà contiene un elenco delle transizioni definite dal gruppo di stati.

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

Vedi anche Transizioni.

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