このページでは

QDragMoveEvent Class

QDragMoveEvent クラスは、ドラッグ&ドロップ操作の進行中に送信されるイベントを提供します。詳細...

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

QDragEnterEvent

パブリック関数

QDragMoveEvent(QPointF pos, Qt::DropActions actions, const QMimeData *data, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, QEvent::Type type = DragMove)
void accept(const QRect &rectangle)
void accept()
QRect answerRect() const
void ignore(const QRect &rectangle)
void ignore()

保護された関数

QDragMoveEvent(QDragMoveEvent &&)
QDragMoveEvent &operator=(QDragMoveEvent &&)
QDragMoveEvent &operator=(const QDragMoveEvent &other)

詳細な説明

ウィジェットがdrop events およびenter events を受け入れる場合、ドラッグがその境界内にある間は、ウィジェットはドラッグ移動イベントを繰り返し受け取ります。ウィジェットはイベントを検証して、どのようなdata が提供されているかを確認し、適切であればaccept()関数を呼び出してドロップを受け入れる必要があります。

answerRect()関数によって提供される矩形を使用することで、ウィジェットの特定の部分へのドロップを制限することができます。例えば、その矩形が特定の子ウィジェットのジオメトリと交差しているかどうかを確認し、交差している場合にのみacceptProposedAction()を呼び出すことができます。

なお、このクラスはその機能の大部分を `QDropEvent` から継承していることに注意してください。

QDragEnterEvent 、QDragLeaveEvent 、およびQDropEventも参照してください 。

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

QDragMoveEvent::QDragMoveEvent(QPointF pos, Qt::DropActions actions, const QMimeData *data, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, QEvent::Type type = DragMove)

指定されたtype を持つQDragMoveEventを作成し、マウスがウィジェット内の指定された位置pos にあることを示します。

マウスおよびキーボードの状態は `buttons ` および `modifiers` によって指定され、`actions ` は実行可能なドラッグ&ドロップ操作の種類を表します。ドラッグデータは、`data` 内の MIME エンコードされた情報として渡されます。

警告: QDragMoveEvent を独自に作成しようとしないでください 。これらのオブジェクトは Qt の内部状態に依存しています。

[protected delete] QDragMoveEvent::QDragMoveEvent(QDragMoveEvent &&)

QDragMoveEvent のインスタンスをmove-constructで生成します。この関数は削除されています。

void QDragMoveEvent::accept(const QRect &rectangle)

accept() と同じですが、ウィジェットで指定されたrectangle の範囲内であれば、今後の移動も受け入れ可能であることを通知します。これによりパフォーマンスが向上する可能性がありますが、基盤となるシステムによって無視される場合もあります。

矩形が空の場合、ドラッグ移動イベントが継続的に送信されます。これは、ソースがタイマーイベント内でスクロールしている場合に役立ちます。

void QDragMoveEvent::accept()

QDropEvent::accept() を呼び出します。

これはオーバーロードされた関数です。

QRect QDragMoveEvent::answerRect() const

ドロップが受け入れられた場合に、ウィジェット内のどの矩形領域にドロップが行われるかを返します。この情報を使用して、ウィジェット上の特定の場所にのみドロップを制限することができます。

void QDragMoveEvent::ignore(const QRect &rectangle)

accept(constQRect&) 関数の逆の動作をします。rectangle 内の移動は許可されず、無視されます。

void QDragMoveEvent::ignore()

QDropEvent::ignore() を呼び出します。

これはオーバーロードされた関数です。

[protected delete] QDragMoveEvent &QDragMoveEvent::operator=(QDragMoveEvent &&)

other をこのQDragMoveEvent インスタンスに割り当てます。この関数は削除されます。

[noexcept protected default] QDragMoveEvent &QDragMoveEvent::operator=(const QDragMoveEvent &other)

other をこのQDragMoveEvent のインスタンスにコピーして割り当てます。

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