IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)

QAbstractTransition Class

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

Article lu   fois.

L'auteur

Liens sociaux

Viadeo Twitter Facebook Share on Google+   

QAbstractTransition Class

  • Header: QAbstractTransition

  • CMake:

    find_package(Qt6 REQUIRED COMPONENTS StateMachine)

    target_link_libraries(mytarget PRIVATE Qt6::StateMachine)

  • qmake: QT += statemachine

  • Inherits: QObject

  • Inherited By: QEventTransition and QSignalTransition

  • Group: QAbstractTransition is part of statemachine

Detailed Description

The QAbstractTransition class is the abstract base class of transitions between states (QAbstractState objects) of a QStateMachine. QAbstractTransition is part of Qt 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.

Member Type Documentation

 

enum QAbstractTransition::TransitionType

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

Constant

Value

Description

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.

See Also

Property Documentation

 

[read-only] sourceState : QState* const

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

Access functions:

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).

Access functions:

Notifier signal:

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.

Access functions:

Notifier signal:

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

[bindable] transitionType : TransitionType

This property supports QProperty bindings.

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.

Member Function Documentation

 

QAbstractTransition::QAbstractTransition(QState *sourceState = 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.

See Also

See also 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.

See Also

See also addAnimation()

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

Reimplements: 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)

Removes the given animation from this transition.

See Also

See also addAnimation()

void QAbstractTransition::setTargetState(QAbstractState *target)

Sets the target state of this transition.

Setter function for property targetState.

See Also

See also targetState()

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

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

Setter function for property targetStates.

See Also

See also targetStates()

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

Sets the type of the transition to type.

Setter function for property transitionType.

See Also

See also 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.

See Also

See also setTargetState()

[since 5.4] void QAbstractTransition::targetStateChanged()

This signal is emitted when the targetState property is changed.

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

Notifier signal for property targetState.

This function was introduced in Qt 5.4.

See Also

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.

See Also

See also setTargetStates()

[since 5.4] void QAbstractTransition::targetStatesChanged()

This signal is emitted when the targetStates property is changed.

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

Notifier signal for property targetStates.

This function was introduced in Qt 5.4.

See Also

QAbstractTransition::TransitionType QAbstractTransition::transitionType() const

Returns the type of the transition.

Getter function for property transitionType.

See Also

See also setTransitionType()

void QAbstractTransition::triggered()

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

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

Vous avez aimé ce tutoriel ? Alors partagez-le en cliquant sur les boutons suivants : Viadeo Twitter Facebook Share on Google+