QAbstractTransition Class

The QAbstractTransition class is the base class of transitions between QAbstractState objects. 更多...

头文件: #include <QAbstractTransition>
qmake: QT += core
开始支持版本: Qt 4.6
基类: QObject
派生类:

QEventTransition and QSignalTransition

公有类型

enum TransitionType { ExternalTransition, InternalTransition }

属性

公有函数

QAbstractTransition(QState *sourceState = Q_NULLPTR)
virtual ~QAbstractTransition()
void addAnimation(QAbstractAnimation *animation)
QList<QAbstractAnimation *> animations() const
QStateMachine *machine() const
void removeAnimation(QAbstractAnimation *animation)
void setTargetState(QAbstractState *target)
void setTargetStates(const QList<QAbstractState *> &targets)
void setTransitionType(TransitionType type)
QState *sourceState() const
QAbstractState *targetState() const
QList<QAbstractState *> targetStates() const
TransitionType transitionType() const
  • 32 个公有函数继承自 QObject

信号

受保护的函数

virtual bool eventTest(QEvent *event) = 0
virtual void onTransition(QEvent *event) = 0

重新实现的受保护函数

virtual bool event(QEvent *e)
  • 9 个受保护的函数继承自 QObject

其他继承的成员

  • 1 个公有槽函数继承自 QObject
  • 11 个静态公有成员继承自 QObject

详细描述

The QAbstractTransition class is the base class of transitions between QAbstractState objects.

The QAbstractTransition class is the abstract base class of transitions between states (QAbstractState objects) of a QStateMachine. QAbstractTransition is part of The State Machine Framework.

The sourceState() function returns the source of the transition. The targetStates() function returns the targets of the transition. The machine() function returns the state machine that the transition is part of.

The triggered() signal is emitted when the transition has been triggered.

Transitions can cause animations to be played. Use the addAnimation() function to add an animation to the transition.

Subclassing

The eventTest() function is called by the state machine to determine whether an event should trigger the transition. In your reimplementation you typically check the event type and cast the event object to the proper type, and check that one or more properties of the event meet your criteria.

The onTransition() function is called when the transition is triggered; reimplement this function to perform custom processing for the transition.

成员类型

enum QAbstractTransition::TransitionType

This enum specifies the kind of transition. By default, the type is an external transition.

ConstantValueDescription
QAbstractTransition::ExternalTransition0Any state that is the source state of a transition (which is not a target-less transition) is left, and re-entered when necessary.
QAbstractTransition::InternalTransition1If the target state of a transition is a sub-state of a compound state, and that compound state is the source state, an internal transition will not leave the source state.

参见 QAbstractTransition::transitionType.

属性

sourceState : QState * const

This property holds the source state (parent) of this transition

访问函数:

QState *sourceState() const

targetState : QAbstractState *

This property holds the target state of this transition

If a transition has no target state, the transition may still be triggered, but this will not cause the state machine's configuration to change (i.e. the current state will not be exited and re-entered).

访问函数:

QAbstractState *targetState() const
void setTargetState(QAbstractState *target)

Notifier signal:

void targetStateChanged()[see note below]

Note: This is a private signal. It can be used in signal connections but cannot be emitted by the user.

targetStates : QList<QAbstractState *>

This property holds the target states of this transition

If multiple states are specified, all must be descendants of the same parallel group state.

访问函数:

QList<QAbstractState *> targetStates() const
void setTargetStates(const QList<QAbstractState *> &targets)

Notifier signal:

void targetStatesChanged()[see note below]

Note: This is a private signal. It can be used in signal connections but cannot be emitted by the user.

transitionType : TransitionType

indicates whether this transition is an internal transition, or an external transition.

Internal and external transitions behave the same, except for the case of a transition whose source state is a compound state and whose target(s) is a descendant of the source. In such a case, an internal transition will not exit and re-enter its source state, while an external one will.

By default, the type is an external transition.

访问函数:

TransitionType transitionType() const
void setTransitionType(TransitionType type)

成员函数

QAbstractTransition::QAbstractTransition(QState *sourceState = Q_NULLPTR)

Constructs a new QAbstractTransition object with the given sourceState.

[virtual] QAbstractTransition::~QAbstractTransition()

Destroys this transition.

void QAbstractTransition::addAnimation(QAbstractAnimation *animation)

Adds the given animation to this transition. The transition does not take ownership of the animation.

参见 removeAnimation() and animations().

QList<QAbstractAnimation *> QAbstractTransition::animations() const

Returns the list of animations associated with this transition, or an empty list if it has no animations.

参见 addAnimation().

[virtual protected] bool QAbstractTransition::event(QEvent *e)

Reimplemented from QObject::event().

[pure virtual protected] bool QAbstractTransition::eventTest(QEvent *event)

This function is called to determine whether the given event should cause this transition to trigger. Reimplement this function and return true if the event should trigger the transition, otherwise return false.

QStateMachine *QAbstractTransition::machine() const

Returns the state machine that this transition is part of, or 0 if the transition is not part of a state machine.

[pure virtual protected] void QAbstractTransition::onTransition(QEvent *event)

This function is called when the transition is triggered. The given event is what caused the transition to trigger. Reimplement this function to perform custom processing when the transition is triggered.

void QAbstractTransition::removeAnimation(QAbstractAnimation *animation)

Removes the given animation from this transition.

参见 addAnimation().

void QAbstractTransition::setTargetState(QAbstractState *target)

Sets the target state of this transition.

Note: Setter function for property targetState.

参见 targetState().

void QAbstractTransition::setTargetStates(const QList<QAbstractState *> &targets)

Sets the target states of this transition to be the given targets.

Note: Setter function for property targetStates.

参见 targetStates().

void QAbstractTransition::setTransitionType(TransitionType type)

Sets the type of the transition to type.

Note: Setter function for property transitionType.

参见 transitionType().

QState *QAbstractTransition::sourceState() const

Returns the source state of this transition, or 0 if this transition has no source state.

Note: Getter function for property sourceState.

QAbstractState *QAbstractTransition::targetState() const

Returns the target state of this transition, or 0 if the transition has no target.

Note: Getter function for property targetState.

参见 setTargetState().

[signal] void QAbstractTransition::targetStateChanged()

This signal is emitted when the targetState property is changed.

This function was introduced in Qt 5.4.

Note: This is a private signal. It can be used in signal connections but cannot be emitted by the user.

Note: Notifier signal for property targetState.

参见 QAbstractTransition::targetState.

QList<QAbstractState *> QAbstractTransition::targetStates() const

Returns the target states of this transition, or an empty list if this transition has no target states.

Note: Getter function for property targetStates.

参见 setTargetStates().

[signal] void QAbstractTransition::targetStatesChanged()

This signal is emitted when the targetStates property is changed.

This function was introduced in Qt 5.4.

Note: This is a private signal. It can be used in signal connections but cannot be emitted by the user.

Note: Notifier signal for property targetStates.

参见 QAbstractTransition::targetStates.

TransitionType QAbstractTransition::transitionType() const

Returns the type of the transition.

Note: Getter function for property transitionType.

参见 setTransitionType().

[signal] void QAbstractTransition::triggered()

This signal is emitted when the transition has been triggered (after onTransition() has been called).

Note: This is a private signal. It can be used in signal connections but cannot be emitted by the user.