The QEventTransition 類提供 QObject 特定過渡為 Qt 事件。 更多...
| 頭: | #include <QEventTransition> |
| qmake: | QT += core |
| Since: | Qt 4.6 |
| 繼承: | QAbstractTransition |
| QEventTransition (QState * sourceState = nullptr) | |
| QEventTransition (QObject * object , QEvent::Type type , QState * sourceState = nullptr) | |
| virtual | ~QEventTransition () |
| QObject * | eventSource () const |
| QEvent::Type | eventType () const |
| void | setEventSource (QObject * object ) |
| void | setEventType (QEvent::Type type ) |
| const QMetaObject | staticMetaObject |
| virtual bool | event (QEvent * e ) override |
| virtual bool | eventTest (QEvent * event ) override |
| virtual void | onTransition (QEvent * event ) override |
The QEventTransition 類提供 QObject 特定過渡為 Qt 事件。
A QEventTransition object binds an event to a particular QObject . QEventTransition 屬於 狀態機框架 .
範例:
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);
當重實現 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.
另請參閱 QState::addTransition ().
This property holds the event source that this event transition is associated with
訪問函數:
| QObject * | eventSource () const |
| void | setEventSource (QObject * object ) |
This property holds the type of event that this event transition is associated with
訪問函數:
| QEvent::Type | eventType () const |
| void | setEventType (QEvent::Type type ) |
構造新的 QEventTransition 對象采用給定 sourceState .
構造新的 QEventTransition object associated with events of the given type 為給定 object ,和采用給定 sourceState .
[虛擬]
QEventTransition::
~QEventTransition
()
銷毀此 QObject event transition.
[override virtual protected]
bool
QEventTransition::
event
(
QEvent
*
e
)
重實現自 QAbstractTransition::event ().
Returns the event source associated with this event transition.
注意: getter 函數對於特性 eventSource .
另請參閱 setEventSource ().
[override virtual protected]
bool
QEventTransition::
eventTest
(
QEvent
*
event
)
重實現自 QAbstractTransition::eventTest ().
Returns the event type that this event transition is associated with.
注意: getter 函數對於特性 eventType .
另請參閱 setEventType ().
[override virtual protected]
void
QEventTransition::
onTransition
(
QEvent
*
event
)
重實現自 QAbstractTransition::onTransition ().
Sets the event source associated with this event transition to be the given object .
注意: setter 函數對於特性 eventSource .
另請參閱 eventSource ().
Sets the event type that this event transition is associated with.
注意: setter 函數對於特性 eventType .
另請參閱 eventType ().