QAbstractTransition 类

QAbstractTransition 类是过渡基类介于 QAbstractState 对象。 更多...

头: #include <QAbstractTransition>
CMake: find_package(Qt6 COMPONENTS StateMachine REQUIRED)
target_link_libraries(mytarget PRIVATE Qt6::StateMachine)
qmake: QT += statemachine
继承: QObject
继承者: QEventTransition and QSignalTransition

公共类型

enum TransitionType { ExternalTransition, InternalTransition }

特性

公共函数

  QAbstractTransition (QState * sourceState = 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 *> & 目标 )
void setTransitionType (QAbstractTransition::TransitionType type )
QState * sourceState () const
QAbstractState * targetState () const
QList<QAbstractState *> targetStates () const
QAbstractTransition::TransitionType transitionType () const

信号

void targetStateChanged ()
void targetStatesChanged ()
void triggered ()

保护函数

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

重实现保护函数

virtual bool event (QEvent * e ) override

详细描述

QAbstractTransition 类是过渡抽象基类介于状态 ( QAbstractState 对象) 的 QStateMachine 。QAbstractTransition 属于 Qt State Machine Framework .

sourceState () 函数返回过渡源。 targetStates () 函数返回过渡目标。 machine () 函数返回过渡所属的状态机。

triggered () 信号发射当过渡被触发时。

过渡可以导致动画播放。使用 addAnimation () 函数以将动画添加到过渡。

子类化

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.

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.

常量 描述
QAbstractTransition::ExternalTransition 0 Any state that is the source state of a transition (which is not a target-less transition) is left, and re-entered when necessary.
QAbstractTransition::InternalTransition 1 If 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 .

特性文档编制

[read-only] sourceState : QState * const

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

访问函数:

QState * sourceState () const

targetState : QAbstractState *

此特性保持此过渡的目标状态

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 )

通知程序信号:

void targetStateChanged () [见下文注意事项]

注意: 这是私有信号。它可以用于信号连接,但不能由用户发射。

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 *> & 目标 )

通知程序信号:

void targetStatesChanged () [见下文注意事项]

注意: 这是私有信号。它可以用于信号连接,但不能由用户发射。

[bindable] transitionType : TransitionType

注意: 此特性支持 QProperty 绑定。

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.

成员函数文档编制

QAbstractTransition:: QAbstractTransition ( QState * sourceState = nullptr)

Constructs a new QAbstractTransition object with the given sourceState .

[private signal, since 5.4] void QAbstractTransition:: targetStateChanged ()

此信号被发射当 targetState 特性改变。

注意: 这是私有信号。它可以用于信号连接,但不能由用户发射。

注意: 通知程序信号对于特性 targetState .

该函数在 Qt 5.4 引入。

另请参阅 QAbstractTransition::targetState .

[private signal, since 5.4] void QAbstractTransition:: targetStatesChanged ()

此信号被发射当 targetStates 特性改变。

注意: 这是私有信号。它可以用于信号连接,但不能由用户发射。

注意: 通知程序信号对于特性 targetStates .

该函数在 Qt 5.4 引入。

另请参阅 QAbstractTransition::targetStates .

[private signal] void QAbstractTransition:: triggered ()

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

注意: 这是私有信号。它可以用于信号连接,但不能由用户发射。

[虚拟] QAbstractTransition:: ~QAbstractTransition ()

Destroys this transition.

void QAbstractTransition:: addAnimation ( QAbstractAnimation * animation )

添加给定 animation to this transition. The transition does not take ownership of the animation.

另请参阅 removeAnimation () 和 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 ().

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

重实现: QObject::event (QEvent *e).

[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 nullptr 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 )

移除给定 animation from this transition.

另请参阅 addAnimation ().

void QAbstractTransition:: setTargetState ( QAbstractState * target )

设置 target state of this transition.

注意: setter 函数对于特性 targetState .

另请参阅 targetState ().

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

Sets the target states of this transition to be the given 目标 .

注意: setter 函数对于特性 targetStates .

另请参阅 targetStates ().

void QAbstractTransition:: setTransitionType ( QAbstractTransition::TransitionType type )

Sets the type of the transition to type .

注意: setter 函数对于特性 transitionType .

另请参阅 transitionType ().

QState *QAbstractTransition:: sourceState () const

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

注意: Getter function for property sourceState.

QAbstractState *QAbstractTransition:: targetState () const

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

注意: Getter function for property targetState.

另请参阅 setTargetState ().

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

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

注意: Getter function for property targetStates.

另请参阅 setTargetStates ().

QAbstractTransition::TransitionType QAbstractTransition:: transitionType () const

Returns the type of the transition.

注意: Getter function for property transitionType.

另请参阅 setTransitionType ().