PySide6.QtStateMachine.QAbstractTransition

class QAbstractTransition

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

Inheritance diagram of PySide6.QtStateMachine.QAbstractTransition

Inherited by: QSignalTransition, QEventTransition, QMouseEventTransition, QKeyEventTransition

Synopsis

Properties

Methods

Virtual methods

Signals

Note

This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE

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.

class TransitionType

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

Constant

Description

QAbstractTransition.ExternalTransition

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

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

transitionType

Note

Properties can be used directly when from __feature__ import true_property is used or via accessor functions otherwise.

property sourceStateᅟ: QState

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

Access functions:
property 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:
property targetStatesᅟ: list of 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:
property transitionTypeᅟ: QAbstractTransition.TransitionType

This property holds 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.

Access functions:
__init__([sourceState=None])
Parameters:

sourceStateQState

Constructs a new QAbstractTransition object with the given sourceState.

addAnimation(animation)
Parameters:

animationQAbstractAnimation

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

animations()
Return type:

.list of QAbstractAnimation

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

See also

addAnimation()

abstract eventTest(event)
Parameters:

eventQEvent

Return type:

bool

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.

machine()
Return type:

QStateMachine

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

abstract onTransition(event)
Parameters:

eventQEvent

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.

removeAnimation(animation)
Parameters:

animationQAbstractAnimation

Removes the given animation from this transition.

See also

addAnimation()

setTargetState(target)
Parameters:

targetQAbstractState

Sets the target state of this transition.

See also

targetState()

Setter of property targetStateᅟ .

setTargetStates(targets)
Parameters:

targets – .list of QAbstractState

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

See also

targetStates()

Setter of property targetStatesᅟ .

setTransitionType(type)
Parameters:

typeTransitionType

Sets the type of the transition to type.

See also

transitionType()

Setter of property transitionTypeᅟ .

sourceState()
Return type:

QState

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

Getter of property sourceStateᅟ .

targetState()
Return type:

QAbstractState

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

See also

setTargetState()

Getter of property targetStateᅟ .

targetStateChanged()

This signal is emitted when the targetState property is changed.

Notification signal of property targetStateᅟ .

targetStates()
Return type:

.list of QAbstractState

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

Getter of property targetStatesᅟ .

targetStatesChanged()

This signal is emitted when the targetStates property is changed.

Notification signal of property targetStatesᅟ .

transitionType()
Return type:

TransitionType

Returns the type of the transition.

Getter of property transitionTypeᅟ .

triggered()

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