The QState 类提供一般目的的状态为 QStateMachine . 更多...
| 头: | #include <QState> |
| Since: | Qt 4.6 |
| 继承: | QAbstractState |
| 继承者: | QStateMachine |
| enum | ChildMode { ExclusiveStates, ParallelStates } |
| QState (QState * parent = 0) | |
| QState (ChildMode childMode , QState * parent = 0) | |
| ~QState () | |
| void | addTransition (QAbstractTransition * transition ) |
| QSignalTransition * | addTransition (QObject * sender , const char * signal , QAbstractState * target ) |
| QAbstractTransition * | addTransition (QAbstractState * target ) |
| void | assignProperty (QObject * object , const char * name , const QVariant & value ) |
| ChildMode | childMode () const |
| QAbstractState * | errorState () const |
| QAbstractState * | initialState () const |
| void | removeTransition (QAbstractTransition * transition ) |
| void | setChildMode (ChildMode mode ) |
| void | setErrorState (QAbstractState * state ) |
| void | setInitialState (QAbstractState * state ) |
| QList<QAbstractTransition *> | transitions () const |
| void | finished () |
| void | propertiesAssigned () |
| virtual bool | event (QEvent * e ) |
| virtual void | onEntry (QEvent * event ) |
| virtual void | onExit (QEvent * event ) |
The QState 类提供一般目的的状态为 QStateMachine .
QState objects can have child states, and can have transitions to other states. QState 属于 状态机框架 .
The addTransition () function adds a transition. The removeTransition () function removes a transition. The transitions () 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 using QStateMachine::addState ().
The 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.
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).
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. |
This property holds the child mode of this state.
此特性的默认值为 QState::ExclusiveStates .
访问函数:
| ChildMode | childMode () const |
| void | setChildMode (ChildMode mode ) |
This property holds the error state of this state.
访问函数:
| QAbstractState * | errorState () const |
| void | setErrorState (QAbstractState * state ) |
This property holds the initial state of this state (one of its child states).
访问函数:
| QAbstractState * | initialState () const |
| void | setInitialState (QAbstractState * state ) |
构造新的状态采用给定 parent 状态。
构造新的状态采用给定 childMode 和给定 parent 状态。
销毁此状态。
添加给定 transition 。过渡拥有此状态因为源。此状态拥有过渡的所有权。
Adds a transition associated with the given signal 为给定 sender 对象,并返回新的 QSignalTransition object. The transition has this state as the source, and the given target as the target state.
Adds an unconditional transition from this state to the given target state, and returns then new transition object.
Instructs this state to set the property with the given name 为给定 object 到给定 value when the state is entered.
另请参阅 propertiesAssigned ().
[virtual protected]
bool
QState::
event
(
QEvent
*
e
)
重实现自 QObject::event ().
[signal]
void
QState::
finished
()
This signal is emitted when a final child state of this state is entered.
另请参阅 QFinalState .
[virtual protected]
void
QState::
onEntry
(
QEvent
*
event
)
重实现自 QAbstractState::onEntry ().
[virtual protected]
void
QState::
onExit
(
QEvent
*
event
)
重实现自 QAbstractState::onExit ().
[signal]
void
QState::
propertiesAssigned
()
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 ().
移除给定 transition from this state. The state releases ownership of the transition.
另请参阅 addTransition ().
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.
该函数在 Qt 4.7 引入。
另请参阅 addTransition ().