QMouseEvent Class
QMouseEventクラスは、マウスイベントを記述するパラメータを含んでいます。詳細...
ヘッダー | #include <QMouseEvent> |
CMake: | find_package(Qt6 REQUIRED COMPONENTS Gui) target_link_libraries(mytarget PRIVATE Qt6::Gui) |
qmake: | QT += gui |
継承: | QSinglePointEvent |
- 継承されたメンバを含むすべてのメンバのリスト
- 非推奨メンバー
- QMouseEventはEventクラスの一部です。
パブリック関数
QMouseEvent(QEvent::Type type, const QPointF &localPos, const QPointF &globalPos, Qt::MouseButton button, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, const QPointingDevice *device = QPointingDevice::primaryPointingDevice()) | |
QMouseEvent(QEvent::Type type, const QPointF &localPos, const QPointF &scenePos, const QPointF &globalPos, Qt::MouseButton button, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, const QPointingDevice *device = QPointingDevice::primaryPointingDevice()) | |
Qt::MouseEventFlags | flags() const |
詳細説明
マウスイベントは、ウィジェット内でマウスボタンが押されたり離されたりしたとき、またはマウスカーソルが移動したときに発生します。
マウスの移動イベントは、マウス・トラッキングがQWidget::setMouseTracking() で有効になっていない限り、マウス・ボタンが押下されたときにのみ発生します。
Qt は、ウィジェット内でマウスボタンが押されると自動的にマウスを捕捉します。ウィジェットは、最後のマウスボタンが離されるまでマウスイベントを受信し続けます。
Qt は、ウィジェット内でマウスボタンが押されると、自動的にマウスをつかみます。マウスイベントがウィジェットで処理されない場合は、ignore() を呼び出す必要があります。マウスイベントは、ウィジェットがaccept() でイベントを受け入れるか、イベントフィルタがイベントを消費するまで、親ウィジェットチェーンに伝搬されます。
注意: マウスイベントがQt::WA_NoMousePropagation が設定されたwidget に伝搬された場合、そのマウスイベントは、親ウィジェットチェーンのそれ以上には伝搬されません。
キーボード修飾キーの状態は、QInputEvent から継承されたmodifiers() 関数を呼び出すことで知ることができます。
position() 関数は、マウスイベントを受信したウィジェットまたはアイテムからの相対的なカーソル位置を与えます。マウス・イベントの結果としてウィジェットを移動する場合は、globalPosition() が返すグローバル位置を使用して、揺れ動きを回避します。
QWidget::setEnabled() 関数を使用すると、ウィジェットのマウス・イベントとキーボード・イベントを有効または無効にできます。
独自のウィジェットでマウス・イベントを受信するには、QWidget イベント・ハンドラ、QWidget::mousePressEvent()、QWidget::mouseReleaseEvent()、QWidget::mouseDoubleClickEvent()、QWidget::mouseMoveEvent() を再実装します。
QWidget::setMouseTracking(),QWidget::grabMouse(),QCursor::pos()も参照してください 。
メンバ関数ドキュメント
QMouseEvent::QMouseEvent(QEvent::Type type, const QPointF &localPos, const QPointF &globalPos, Qt::MouseButton button, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, const QPointingDevice *device = QPointingDevice::primaryPointingDevice())
device を起点とするマウス・イベント・オブジェクトを構築する。
type パラメータはQEvent::MouseButtonPress,QEvent::MouseButtonRelease,QEvent::MouseButtonDblClick, またはQEvent::MouseMove でなければならない。
localPos は、受信ウィジェットまたはアイテムに対するマウスカーソルの相対位置である。スクリーン座標におけるカーソルの位置は、globalPos で指定される。ウィンドウ位置はlocalPos と同じ値に設定される。イベントの原因となったbutton は、Qt::MouseButton enum の値として与えられる。イベントtype がMouseMove の場合、このイベントに適切なボタンはQt::NoButton である。buttons はイベント発生時のすべてのボタンの状態、modifiers はすべてのキーボード修飾子の状態である。
QMouseEvent::QMouseEvent(QEvent::Type type, const QPointF &localPos, const QPointF &scenePos, const QPointF &globalPos, Qt::MouseButton button, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, const QPointingDevice *device = QPointingDevice::primaryPointingDevice())
マウス・イベント・オブジェクトを構築する。
type パラメータには、QEvent::MouseButtonPress 、QEvent::MouseButtonRelease 、QEvent::MouseButtonDblClick 、QEvent::MouseMove のいずれかを指定する。
ポイントlocalPos 、scenePos 、globalPos は、それぞれ受信ウィジェットまたはアイテム、ウィンドウ、画面またはデスクトップに対するマウスカーソルの相対位置を指定する。
イベントの原因となったbutton は、Qt::MouseButton 列挙型の値として与えられる。イベントtype がMouseMove の場合、このイベントに適切なボタンはQt::NoButton である。buttons はイベント発生時のすべてのボタンの状態であり、modifiers はすべてのキーボード修飾子の状態である。
Qt::MouseEventFlags QMouseEvent::flags() const
マウスイベントフラグを返します。
マウス・イベント・フラグは、マウス・イベントに関する追加情報を提供する。
Qt::MouseEventFlag およびQGraphicsSceneMouseEvent::flags()も参照してください 。
© 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.