QState¶
The
QState
class provides a general-purpose state forQStateMachine
. More…
Inherited by: QStateMachine
New in version 4.6.
Synopsis¶
Functions¶
def
addTransition
(arg__1, arg__2)def
addTransition
(sender, signal, target)def
addTransition
(target)def
addTransition
(transition)def
assignProperty
(object, name, value)def
childMode
()def
errorState
()def
initialState
()def
removeTransition
(transition)def
setChildMode
(mode)def
setErrorState
(state)def
setInitialState
(state)def
transitions
()
Detailed Description¶
QState
objects can have child states, and can have transitions to other states.QState
is part of The State Machine Framework .The
addTransition()
function adds a transition. TheremoveTransition()
function removes a transition. Thetransitions()
function returns the state’s outgoing transitions.The
assignProperty()
function is used for defining property assignments that should be performed when a state is entered.Top-level states must be passed a
QStateMachine
object as their parent state, or added to a state machine usingaddState()
.
States with Child States¶
The
childMode
property determines how child states are treated. For non-parallel state groups, thesetInitialState()
function must be called to set the initial state. The child states are mutually exclusive states, and the state machine needs to know which child state to enter when the parent state is the target of a transition.The state emits the
finished()
signal when a final child state (QFinalState
) is entered.The
setErrorState()
sets the state’s error state. The error state is the state that the state machine will transition to if an error is detected when attempting to enter the state (e.g. because no initial state has been set).
- class PySide2.QtCore.QState([parent=None])¶
PySide2.QtCore.QState(childMode[, parent=None])
- param parent:
- param childMode:
Constructs a new state with the given
parent
state.Constructs a new state with the given
childMode
and the givenparent
state.
- PySide2.QtCore.QState.ChildMode¶
This enum specifies how a state’s child states are treated.
Constant
Description
QState.ExclusiveStates
The child states are mutually exclusive and an initial state must be set by calling
setInitialState()
.QState.ParallelStates
The child states are parallel. When the parent state is entered, all its child states are entered in parallel.
- PySide2.QtCore.QState.RestorePolicy¶
This enum specifies the restore policy type. The restore policy takes effect when the machine enters a state which sets one or more properties. If the restore policy is set to , the state machine will save the original value of the property before the new value is set.
Later, when the machine either enters a state which does not set a value for the given property, the property will automatically be restored to its initial value.
Only one initial value will be saved for any given property. If a value for a property has already been saved by the state machine, it will not be overwritten until the property has been successfully restored.
Constant
Description
QState.DontRestoreProperties
The state machine should not save the initial values of properties and restore them later.
QState.RestoreProperties
The state machine should save the initial values of properties and restore them later.
See also
- PySide2.QtCore.QState.addTransition(arg__1, arg__2)¶
- Parameters:
arg__1 – object
arg__2 –
PySide2.QtCore.QAbstractState
- Return type:
- PySide2.QtCore.QState.addTransition(target)
- Parameters:
target –
PySide2.QtCore.QAbstractState
- Return type:
Adds an unconditional transition from this state to the given
target
state, and returns then new transition object.
- PySide2.QtCore.QState.addTransition(transition)
- Parameters:
transition –
PySide2.QtCore.QAbstractTransition
Adds the given
transition
. The transition has this state as the source. This state takes ownership of the transition.
- PySide2.QtCore.QState.addTransition(sender, signal, target)
- Parameters:
sender –
PySide2.QtCore.QObject
signal – str
target –
PySide2.QtCore.QAbstractState
- Return type:
Adds a transition associated with the given
signal
of the givensender
object, and returns the newQSignalTransition
object. The transition has this state as the source, and the giventarget
as the target state.
- PySide2.QtCore.QState.assignProperty(object, name, value)¶
- Parameters:
object –
PySide2.QtCore.QObject
name – str
value – object
Instructs this state to set the property with the given
name
of the givenobject
to the givenvalue
when the state is entered.See also
propertiesAssigned()
- PySide2.QtCore.QState.childMode()¶
- Return type:
This property holds the child mode of this state.
The default value of this property is
ExclusiveStates
.
- PySide2.QtCore.QState.errorState()¶
- Return type:
This property holds the error state of this state.
- PySide2.QtCore.QState.initialState()¶
- Return type:
This property holds the initial state of this state (one of its child states).
- PySide2.QtCore.QState.removeTransition(transition)¶
- Parameters:
transition –
PySide2.QtCore.QAbstractTransition
Removes the given
transition
from this state. The state releases ownership of the transition.See also
- PySide2.QtCore.QState.setChildMode(mode)¶
- Parameters:
mode –
ChildMode
This property holds the child mode of this state.
The default value of this property is
ExclusiveStates
.
- PySide2.QtCore.QState.setErrorState(state)¶
- Parameters:
state –
PySide2.QtCore.QAbstractState
This property holds the error state of this state.
- PySide2.QtCore.QState.setInitialState(state)¶
- Parameters:
state –
PySide2.QtCore.QAbstractState
This property holds the initial state of this state (one of its child states).
- PySide2.QtCore.QState.transitions()¶
- Return type:
Returns this state’s outgoing transitions (i.e. transitions where this state is the
source state
), or an empty list if this state has no outgoing transitions.See also
© 2022 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.