QContextMenuEvent Class

QContextMenuEventクラスは、コンテキストメニューイベントを記述するパラメータを含んでいます。詳細...

ヘッダー #include <QContextMenuEvent>
CMake: find_package(Qt6 REQUIRED COMPONENTS Gui)
target_link_libraries(mytarget PRIVATE Qt6::Gui)
qmake: QT += gui
継承: QInputEvent

パブリックタイプ

enum Reason { Mouse, Keyboard, Other }

パブリック関数

QContextMenuEvent(QContextMenuEvent::Reason reason, const QPoint &pos, const QPoint &globalPos, Qt::KeyboardModifiers modifiers = Qt::NoModifier)
const QPoint &globalPos() const
int globalX() const
int globalY() const
const QPoint &pos() const
QContextMenuEvent::Reason reason() const
int x() const
int y() const

詳細説明

コンテキストメニューイベントは、ユーザがコンテキストメニューを開くためのアクションを実行すると、ウィジェットに送られます。コンテキストメニューを開くために必要なアクションは、プラットフォームによって異なります。例えば、Windows では、メニューボタンを押すか、マウスの右ボタンをクリックすると、このイベントが送信されます。

このイベントが発生すると、コンテキストに関連するものであれば、コンテキストメニューとともにQMenu

メンバー型ドキュメント

enum QContextMenuEvent::Reason

この列挙型は、イベントが送信された理由を記述する。

定数説明
QContextMenuEvent::Mouse0マウスによってイベントが送信されました。通常、これはマウスの右ボタンがクリックされたことを意味しますが、これはプラットフォームに依存します。
QContextMenuEvent::Keyboard1キーボードによって、このイベントが送信されました。Windowsでは、メニューボタンが押されたことを意味する。
QContextMenuEvent::Other2マウスでもキーボードでもない)他の手段でイベントが送られた。

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

QContextMenuEvent::QContextMenuEvent(QContextMenuEvent::Reason reason, const QPoint &pos, const QPoint &globalPos, Qt::KeyboardModifiers modifiers = Qt::NoModifier)

acceptパラメータフラグをfalseに設定したコンテキストメニューイベントオブジェクトを構築する。

reason パラメータにはQContextMenuEvent::Mouse またはQContextMenuEvent::Keyboard を指定します。

pos パラメータは、受信ウィジェットからの相対的なマウス位置を指定します。globalPos は、絶対座標でのマウス位置です。modifiers には、キーボード修飾子を指定します。

const QPoint &QContextMenuEvent::globalPos() const

イベント発生時のマウスポインタのグローバル位置を返します。

x(),y(),pos()も参照

int QContextMenuEvent::globalX() const

イベント発生時のマウスポインタのグローバル x 位置を返す。

globalY() およびglobalPos()も参照

int QContextMenuEvent::globalY() const

イベント発生時のマウスポインタのグローバルy位置を返す。

globalX() およびglobalPos()も参照

const QPoint &QContextMenuEvent::pos() const

イベントを受け取ったウィジェットからの相対的なマウスポインタの位置を返します。

x(),y(),globalPos()も参照してください

QContextMenuEvent::Reason QContextMenuEvent::reason() const

このコンテキストイベントの理由を返します。

int QContextMenuEvent::x() const

イベントを受け取ったウィジェットからの相対的なマウスポインタの x 位置を返します。

y() およびpos()も参照してください

int QContextMenuEvent::y() const

イベントを受け取ったウィジェットからの相対的なマウスポインタの y 位置を返します。

x() およびpos()も参照してください

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