QGraphicsSceneEvent Class

QGraphicsSceneEventクラスは、すべてのグラフィックスビュー関連イベントの基本クラスを提供します。詳細...

ヘッダー #include <QGraphicsSceneEvent>
CMake: find_package(Qt6 REQUIRED COMPONENTS Widgets)
target_link_libraries(mytarget PRIVATE Qt6::Widgets)
qmake: QT += widgets
を継承する: QEvent
によって継承される:

QGraphicsSceneContextMenuEvent,QGraphicsSceneDragDropEvent,QGraphicsSceneHelpEvent,QGraphicsSceneHoverEvent,QGraphicsSceneMouseEvent,QGraphicsSceneMoveEvent,QGraphicsSceneResizeEvent, およびQGraphicsSceneWheelEvent

パブリック関数

virtual ~QGraphicsSceneEvent()
(since 6.2) quint64 timestamp() const
QWidget *widget() const

詳細説明

QGraphicsView が Qt のマウス、キーボード、ドラッグ&ドロップ イベント (QMouseEvent,QKeyEvent, QDragEvent など) を受信すると、それらを QGraphicsSceneEvent サブクラスのインスタンスに変換し、表示するQGraphicsScene に転送します。その後、シーンはイベントを関連するアイテムに転送します。

例えば、QGraphicsView がユーザーのクリックに対するレスポンスとして MousePress タイプのQMouseEvent を受信すると、ビューはそのmousePressEvent() 関数を通して、QGraphicsScene に GraphicsSceneMousePress タイプのQGraphicsSceneMouseEvent を送信します。デフォルトのQGraphicsScene::mousePressEvent() 実装は、どのアイテムがクリックされたかを判断し、QGraphicsItem::mousePressEvent() にイベントを転送します。

QGraphicsSceneMouseEventQGraphicsSceneContextMenuEvent などのサブクラスは、元のQEvent からの座標をスクリーン座標、シーン座標、アイテム座標で提供します(screenPos()、scenePos()、pos() を参照)。アイテム座標は、QGraphicsItem にイベントを転送する前に、QGraphicsScene によって設定されます。 マウスイベントは、ビューが最後に受信したイベントから座標を取得する可能性も追加します(lastScreenPos()、lastScenePos()、lastPos() を参照)。

QEventも参照

メンバ関数ドキュメント

[virtual noexcept] QGraphicsSceneEvent::~QGraphicsSceneEvent()

イベントを破壊する。

[since 6.2] quint64 QGraphicsSceneEvent::timestamp() const

元のイベントのタイムスタンプを返し、元のイベントがタイムスタンプを報告しない場合は 0 を返します。

この関数は Qt 6.2 で導入されました。

QWidget *QGraphicsSceneEvent::widget() const

イベントが発生したウィジェット、またはイベントが他のアプリケーションから発生した場合はnullptr を返します。

© 2025 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.