このページでは

QEventTransition Class

QEventTransition クラスは、Qt イベント向けにQObject 専用の遷移機能を提供します。詳細...

ヘッダー: #include <QEventTransition>
CMake: find_package(Qt6 REQUIRED COMPONENTS StateMachine)
target_link_libraries(mytarget PRIVATE Qt6::StateMachine)
qmake: QT += statemachine
継承元: QAbstractTransition
継承元:

QKeyEventTransition およびQMouseEventTransition

プロパティ

パブリック関数

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)

再実装された保護関数

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

詳細な説明

QEventTransition オブジェクトは、イベントを特定のQObject に紐付けます。QEventTransitionは、Qt State Machine フレームワークの一部です。

例:

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() 関数を再実装する際は、まず基底クラスの実装を呼び出して、そのイベントが適切なオブジェクトおよびイベントタイプに対するQStateMachine::WrappedEvent であることを確認する必要があります。その後、イベントをQStateMachine::WrappedEvent にキャストし、QStateMachine::WrappedEvent::event() を呼び出して元のイベントを取得し、そのオブジェクトに対して追加のチェックを行うことができます。

QState::addTransition()も参照してください 。

プロパティのドキュメント

[bindable] eventSource : QObject*

注:この プロパティは、QProperty バインディングをサポートしています。

このプロパティには、このイベント遷移が関連付けられているイベントソースが格納されます。

アクセス関数:

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

[bindable] eventType : QEvent::Type

注:この プロパティは、QProperty バインディングに対応しています。

このプロパティは、このイベント遷移が関連付けられているイベントの型を保持します

アクセス関数:

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

メンバー関数のドキュメント

QEventTransition::QEventTransition(QState *sourceState = nullptr)

指定されたsourceState を使用して、新しいQEventTransitionオブジェクトを作成します。

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

type 指定されたobject に対して、指定された のイベントに関連付けられ、かつ指定されたsourceState を持つ新しいQEventTransitionオブジェクトを生成します。

[virtual noexcept] QEventTransition::~QEventTransition()

QObject のイベント遷移を破棄します。

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

QAbstractTransition::event(QEvent *e) を再実装します。

QObject *QEventTransition::eventSource() const

このイベント遷移に関連付けられたイベントソースを返します。

注: プロパティ eventSourceのゲッター関数です 。

関連項目: setEventSource()。

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

QAbstractTransition::eventTest(QEvent *event) を再実装します。

QEvent::Type QEventTransition::eventType() const

このイベント遷移が関連付けられているイベントタイプを返します。

注: プロパティ `eventType`のゲッター関数です 。

関連項目: setEventType()。

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

QAbstractTransition::onTransition(QEvent *event) の再実装です。

void QEventTransition::setEventSource(QObject *object)

このイベント遷移に関連付けられているイベントソースを、指定されたobject に設定します。

注: プロパティ `eventSource`のセッター 関数です。

eventSource()も参照してください 。

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

このイベント遷移に関連付けられているイベント「type 」を設定します。

注: プロパティeventType のセッター 関数です。

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