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

QEventTransition Class

The QEventTransition class provides a QObject-specific transition for Qt events.

Article lu   fois.

L'auteur

Liens sociaux

Viadeo Twitter Facebook Share on Google+   

QEventTransition Class

  • Header: QEventTransition

  • CMake:

    find_package(Qt6 REQUIRED COMPONENTS StateMachine)

    target_link_libraries(mytarget PRIVATE Qt6::StateMachine)

  • qmake: QT += statemachine

  • Inherits: QAbstractTransition

  • Inherited By: QKeyEventTransition and QMouseEventTransition

  • Group: QEventTransition is part of statemachine

Detailed Description

A QEventTransition object binds an event to a particular QObject. QEventTransition is part of Qt State Machine Framework.

Example:

 
Sélectionnez
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);

Subclassing

When reimplementing the eventTest() function, you should first call the base implementation to verify that the event is a QStateMachine::WrappedEvent for the proper object and event type. You may then cast the event to a QStateMachine::WrappedEvent and get the original event by calling QStateMachine::WrappedEvent::event(), and perform additional checks on that object.

See Also

Property Documentation

 

[bindable] eventSource : QObject*

This property supports QProperty bindings.

This property holds the event source that this event transition is associated with

[bindable] eventType : QEvent::Type

This property supports QProperty bindings.

This property holds the type of event that this event transition is associated with

Member Function Documentation

 

QEventTransition::QEventTransition(QState *sourceState = nullptr)

Constructs a new QEventTransition object with the given sourceState.

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

Constructs a new QEventTransition object associated with events of the given type for the given object, and with the given sourceState.

[virtual] QEventTransition::~QEventTransition()

Destroys this QObject event transition.

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

QObject *QEventTransition::eventSource() const

Returns the event source associated with this event transition.

Getter function for property eventSource.

See Also

See also setEventSource()

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

QEvent::Type QEventTransition::eventType() const

Returns the event type that this event transition is associated with.

Getter function for property eventType.

See Also

See also setEventType()

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

void QEventTransition::setEventSource(QObject *object)

Sets the event source associated with this event transition to be the given object.

Setter function for property eventSource.

See Also

See also eventSource()

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

Sets the event type that this event transition is associated with.

Setter function for property eventType.

See Also

See also eventType()

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