QStateclass provides a general-purpose state forQStateMachine. 更多 …
继承者: QStateMachine
4.6 版新增。
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
过渡
()
QStateobjects can have child states, and can have transitions to other states.QStateis part of 状态机框架 .
addTransition()function adds a transition. TheremoveTransition()function removes a transition. Thetransitions()function returns the state’s outgoing transitions.
assignProperty()function is used for defining property assignments that should be performed when a state is entered.Top-level states must be passed a
QStateMachineobject as their parent state, or added to a state machine usingaddState().
childModeproperty 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.
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).
QState
(
[
parent=None
]
)
¶
QState(childMode[, parent=None])
- param parent
- param childMode
ChildMode
Constructs a new state with the given
parent
状态。
Constructs a new state with the given
childMode
和给定
parent
状态。
PySide2.QtCore.QState.
ChildMode
¶
This enum specifies how a state’s child states are treated.
|
常量 |
描述 |
|---|---|
|
QState.ExclusiveStates |
The child states are mutually exclusive and an initial state must be set by calling
|
|
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.
|
常量 |
描述 |
|---|---|
|
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. |
PySide2.QtCore.QState.
addTransition
(
arg__1
,
arg__2
)
¶
arg__1
–
PyObject
arg__2
–
QAbstractState
PySide2.QtCore.QState.
addTransition
(
target
)
¶
target
–
QAbstractState
Adds an unconditional transition from this state to the given
target
state, and returns then new transition object.
PySide2.QtCore.QState.
addTransition
(
transition
)
¶
transition
–
QAbstractTransition
添加给定
transition
. The transition has this state as the source. This state takes ownership of the transition.
PySide2.QtCore.QState.
addTransition
(
sender
,
signal
,
target
)
¶
sender
–
QObject
signal – str
target
–
QAbstractState
Adds a transition associated with the given
signal
为给定
sender
object, and returns the new
QSignalTransition
object. The transition has this state as the source, and the given
target
as the target state.
PySide2.QtCore.QState.
assignProperty
(
object
,
name
,
value
)
¶
object
–
QObject
name – str
value – object
Instructs this state to set the property with the given
name
为给定
object
到给定
value
when the state is entered.
另请参阅
propertiesAssigned()
PySide2.QtCore.QState.
childMode
(
)
¶
Returns the child mode of this state.
另请参阅
PySide2.QtCore.QState.
errorState
(
)
¶
Returns this state’s error state.
另请参阅
PySide2.QtCore.QState.
initialState
(
)
¶
Returns this state’s initial state, or
None
if the state has no initial state.
另请参阅
PySide2.QtCore.QState.
removeTransition
(
transition
)
¶
transition
–
QAbstractTransition
移除给定
transition
from this state. The state releases ownership of the transition.
另请参阅
PySide2.QtCore.QState.
setChildMode
(
mode
)
¶
mode
–
ChildMode
Sets the child
mode
of this state.
另请参阅
PySide2.QtCore.QState.
setErrorState
(
state
)
¶
state
–
QAbstractState
Sets this state’s error state to be the given
state
. If the error state is not set, or if it is set to
None
, the state will inherit its parent’s error state recursively. If no error state is set for the state itself or any of its ancestors, an error will cause the machine to stop executing and an error will be printed to the console.
另请参阅
PySide2.QtCore.QState.
setInitialState
(
state
)
¶
state
–
QAbstractState
Sets this state’s initial state to be the given
state
.
state
has to be a child of this state.
另请参阅
PySide2.QtCore.QState.
过渡
(
)
¶
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.
另请参阅