En esta página

QEventTransition Class

La clase QEventTransition proporciona una transición específica QObject para eventos Qt. Más...

Cabecera: #include <QEventTransition>
CMake: find_package(Qt6 REQUIRED COMPONENTS StateMachine)
target_link_libraries(mytarget PRIVATE Qt6::StateMachine)
qmake: QT += statemachine
Hereda: QAbstractTransition
Heredado por:

QKeyEventTransition y QMouseEventTransition

Propiedades

Funciones públicas

QEventTransition(QState *sourceState = nullptr)
QEventTransition(QObject *object, QEvent::Type type, QState *sourceState = nullptr)
virtual ~QEventTransition()
QBindable<QObject *> bindableEventSource()
QBindable<QEvent::Type> bindableEventType()
QObject *eventSource() const
QEvent::Type eventType() const
void setEventSource(QObject *object)
void setEventType(QEvent::Type type)

Funciones protegidas reimplementadas

virtual bool event(QEvent *e) override
virtual bool eventTest(QEvent *event) override
virtual void onTransition(QEvent *event) override

Descripción detallada

Un objeto QEventTransition vincula un evento a un QObject particular. QEventTransition forma parte de Qt State Machine Framework.

Ejemplo:

QPushButton *button = ...;
QState *s1 = ...;
QState *s2 = ...;
// If in s1 and the button receives an Enter event, transition to s2
QEventTransition *enterTransition = new QEventTransition(button, QEvent::Enter);
enterTransition->setTargetState(s2);
s1->addTransition(enterTransition);
// If in s2 and the button receives an Exit event, transition back to s1
QEventTransition *leaveTransition = new QEventTransition(button, QEvent::Leave);
leaveTransition->setTargetState(s1);
s2->addTransition(leaveTransition);

Subclasificación de

Al reimplementar la función eventTest(), primero debe llamar a la implementación base para verificar que el evento es un QStateMachine::WrappedEvent para el objeto y tipo de evento adecuados. A continuación, puede convertir el evento en un QStateMachine::WrappedEvent y obtener el evento original llamando a QStateMachine::WrappedEvent::event(), y realizar comprobaciones adicionales en ese objeto.

Véase también QState::addTransition().

Documentación de propiedades

[bindable] eventSource : QObject*

Nota: Esta propiedad soporta enlaces QProperty.

Esta propiedad contiene el origen del evento al que está asociada esta transición de evento

Funciones de acceso:

QObject *eventSource() const
void setEventSource(QObject *object)

[bindable] eventType : QEvent::Type

Nota: Esta propiedad soporta enlaces QProperty.

Esta propiedad contiene el tipo de evento al que está asociada esta transición de evento

Funciones de acceso:

QEvent::Type eventType() const
void setEventType(QEvent::Type type)

Documentación de la función de miembro

QEventTransition::QEventTransition(QState *sourceState = nullptr)

Construye un nuevo objeto QEventTransition con la dirección sourceState.

QEventTransition::QEventTransition(QObject *object, QEvent::Type type, QState *sourceState = nullptr)

Construye un nuevo objeto QEventTransition asociado con eventos del type dado para el object dado , y con el sourceState dado.

[virtual noexcept] QEventTransition::~QEventTransition()

Destruye esta transición de eventos QObject.

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

Reimplementa: QAbstractTransition::event(QEvent *e).

QObject *QEventTransition::eventSource() const

Devuelve el origen del evento asociado con esta transición de evento.

Nota: Función Getter para la propiedad eventSource.

Ver también setEventSource().

[override virtual protected] bool QEventTransition::eventTest(QEvent *event)

Reimplementa: QAbstractTransition::eventTest(QEvent *event).

QEvent::Type QEventTransition::eventType() const

Devuelve el tipo de evento al que está asociada esta transición de evento.

Nota: Función Getter para la propiedad eventType.

Véase también setEventType().

[override virtual protected] void QEventTransition::onTransition(QEvent *event)

Reimplementa: QAbstractTransition::onTransition(QEvent *event).

void QEventTransition::setEventSource(QObject *object)

Establece la fuente de eventos asociada a esta transición de eventos como object.

Nota: Función Setter para la propiedad eventSource.

Ver también eventSource().

void QEventTransition::setEventType(QEvent::Type type)

Establece el evento type al que está asociada esta transición de evento.

Nota: Función Setter para la propiedad eventType.

Ver también eventType().

© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.