QState Class Reference

[ QtCore module]

The QState class provides a general-purpose state for QStateMachine . 更多...

继承 QAbstractState .

Inherited by QStateMachine .

类型

方法

Qt Signals


详细描述

The QState class provides a general-purpose state for QStateMachine .

QState objects can have child states, and can have transitions to other states. QState is part of 状态机框架 .

addTransition () function adds a transition. The removeTransition () function removes a transition. The 过渡 () 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 QStateMachine object as their parent state, or added to a state machine using QStateMachine.addState ().

States with Child States

childMode property determines how child states are treated. For non-parallel state groups, the setInitialState () 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 QState.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.ChildMode

This enum specifies how a state's child states are treated.

常量 描述
QState.ExclusiveStates 0 The child states are mutually exclusive and an initial state must be set by calling QState.setInitialState ().
QState.ParallelStates 1 The child states are parallel. When the parent state is entered, all its child states are entered in parallel.

方法文档编制

QState.__init__ ( self , QState   parent  = None)

parent argument, if not None, causes self to be owned by Qt instead of PyQt.

Constructs a new state with the given parent 状态。

QState.__init__ ( self , ChildMode   childMode , QState   parent  = None)

parent argument, if not None, causes self to be owned by Qt instead of PyQt.

Constructs a new state with the given childMode 和 given parent 状态。

QState.addTransition ( self , QAbstractTransition   transition )

transition argument has it's ownership transferred to Qt.

添加给定 transition . The transition has this state as the source. This state takes ownership of the transition.

QSignalTransition QState.addTransition ( self , QObject   sender , SIGNAL()  signal , QAbstractState   target )

Adds a transition associated with the given signal 的 given sender object, and returns the new QSignalTransition 对象。 transition has this state as the source, and the given target as the target state.

QSignalTransition QState.addTransition ( self , signal  signal , QAbstractState   target )

Adds an unconditional transition from this state to the given target state, and returns then new transition object.

QAbstractTransition QState.addTransition ( self , QAbstractState   target )

target argument has it's ownership transferred to Qt.

QState.assignProperty ( self , QObject   object , str  name , QVariant  value )

Instructs this state to set the property with the given name of the given object 到给定 value when the state is entered.

另请参阅 propertiesAssigned ().

ChildMode QState.childMode ( self )

QAbstractState QState.errorState ( self )

bool QState.event ( self , QEvent   e )

重实现自 QObject.event ().

QAbstractState QState.initialState ( self )

QState.onEntry ( self , QEvent   event )

重实现自 QAbstractState.onEntry ().

QState.onExit ( self , QEvent   event )

重实现自 QAbstractState.onExit ().

QState.removeTransition ( self , QAbstractTransition   transition )

transition argument

移除给定 transition from this state. The state releases ownership of the transition.

另请参阅 addTransition ().

QState.setChildMode ( self , ChildMode   mode )

QState.setErrorState ( self , QAbstractState   state )

QState.setInitialState ( self , QAbstractState   state )

list-of-QAbstractTransition QState.transitions ( self )

Returns this state's outgoing transitions (i.e. transitions where this state is the source state ),或 an empty list if this state has no outgoing transitions.

该函数在 Qt 4.7 引入。

另请参阅 addTransition ().


Qt Signal Documentation

void finished ()

This is the default overload of this signal.

This signal is emitted when a final child state of this state is entered.

另请参阅 QFinalState .

void propertiesAssigned ()

This is the default overload of this signal.

This signal is emitted when all properties have been assigned their final value. If the state assigns a value to one or more properties for which an animation exists (either set on the transition or as a default animation on the state machine), then the signal will not be emitted until all such animations have finished playing.

If there are no relevant animations, or no property assignments defined for the state, then the signal will be emitted immediately before the state is entered.

另请参阅 QState.assignProperty () 和 QAbstractTransition.addAnimation ().