QGraphicsSceneDragDropEvent Class
QGraphicsSceneDragDropEvent クラスは、グラフィックスビューフレームワークにおけるドラッグ&ドロップのイベントを提供します。詳細...
| ヘッダー: | #include <QGraphicsSceneDragDropEvent> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS Widgets) target_link_libraries(mytarget PRIVATE Qt6::Widgets) |
| qmake: | QT += widgets |
| 継承元: | QGraphicsSceneEvent |
パブリック関数
| virtual | ~QGraphicsSceneDragDropEvent() |
| void | acceptProposedAction() |
| Qt::MouseButtons | buttons() const |
| Qt::DropAction | dropAction() const |
| const QMimeData * | mimeData() const |
| Qt::KeyboardModifiers | modifiers() const |
| QPointF | pos() const |
| Qt::DropActions | possibleActions() const |
| Qt::DropAction | proposedAction() const |
| QPointF | scenePos() const |
| QPoint | screenPos() const |
| void | setDropAction(Qt::DropAction action) |
| QWidget * | source() const |
詳細な説明
QGraphicsView QWidget が提供するドラッグ&ドロップ機能を継承します。ドラッグ&ドロップイベントを受信すると、それをQGraphicsSceneDragDropEventに変換します。
QGraphicsSceneDragDropEventは、GraphicsSceneDragEnter、GraphicsSceneDragLeave、GraphicsSceneDragMove、またはGraphicsSceneDrop型のイベントを格納します。
QGraphicsSceneDragDropEvent には、アイテム座標、シーン座標、および画面座標のすべてにおけるマウスカーソルの位置が含まれています。これは、pos()、scenePos()、およびscreenPos() を使用して取得できます。
シーンは、マウスカーソルの下にあるドロップを受け入れる最初のQGraphicsItem にイベントを送信します。グラフィックス・アイテムは、setAcceptDrops() によってドロップを受け入れるように設定されます。
メンバ関数のドキュメント
[virtual noexcept] QGraphicsSceneDragDropEvent::~QGraphicsSceneDragDropEvent()
そのオブジェクトを破棄します。
void QGraphicsSceneDragDropEvent::acceptProposedAction()
提案されたアクションを「承認済み」として設定します。つまり、ドロップアクションが提案されたアクションに設定されます。これは、以下のコードと同じ効果があります:
setDropAction(proposedAction());この関数を使用する際は、accept() を呼び出してはなりません。
dropAction()、setDropAction()、およびproposedAction()も参照してください 。
Qt::MouseButtons QGraphicsSceneDragDropEvent::buttons() const
このマウスイベントが発生した際に、マウスのどのボタンが押されていたかを示すQt::MouseButtons 値を返します。
「Qt::MouseButtons」も参照してください 。
Qt::DropAction QGraphicsSceneDragDropEvent::dropAction() const
このドラッグ&ドロップで実行されたアクションを返します。これはドロップ先のオブジェクトによって設定されるべきものであり、QDrag::exec() によって返されます。
setDropAction() およびacceptProposedAction()も参照してください 。
const QMimeData *QGraphicsSceneDragDropEvent::mimeData() const
この関数は、イベントのMIMEデータを返します。
Qt::KeyboardModifiers QGraphicsSceneDragDropEvent::modifiers() const
ドラッグ&ドロップイベントが発生した際に押されていたキーボード修飾キーを返します。
Qt::KeyboardModifiersも参照してください 。
QPointF QGraphicsSceneDragDropEvent::pos() const
イベントを送信したビューを基準として、そのイベントのマウス位置を返します。
QGraphicsView 、screenPos()、およびscenePos()も参照してください 。
Qt::DropActions QGraphicsSceneDragDropEvent::possibleActions() const
ドラッグ&ドロップによって発生しうるドロップ操作を返します。
Qt::DropActionsも参照してください 。
Qt::DropAction QGraphicsSceneDragDropEvent::proposedAction() const
提案されている(つまり、推奨される)ドロップアクションを返します。このアクションは、possibleActions() で定義されている可能なアクションのいずれかでなければなりません。
Qt::DropAction およびpossibleActions()も参照してください 。
QPointF QGraphicsSceneDragDropEvent::scenePos() const
シーン座標系におけるマウスの位置を返します。
pos() およびscreenPos()も参照してください 。
QPoint QGraphicsSceneDragDropEvent::screenPos() const
画面に対するマウスの位置を返します。
pos() およびscenePos()も参照してください 。
void QGraphicsSceneDragDropEvent::setDropAction(Qt::DropAction action)
この関数を使用すると、ドロップの受信側は、実行されたドロップ操作を `action` に設定できます。この値は、possible actions のいずれかである必要があります。この関数を使用する場合は、`acceptProposedAction() ` の代わりに `accept() ` を呼び出してください。
dropAction()、accept()、およびpossibleActions()も参照してください 。
QWidget *QGraphicsSceneDragDropEvent::source() const
この関数は、QGraphicsSceneDragDropEvent を作成したQGraphicsView を返します。
© 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.