QDropEvent 類

QDropEvent 類提供被發送的事件當拖放操作完成時。 更多...

頭: #include <QDropEvent>
qmake: QT += gui
繼承: QEvent
繼承者:

QDragMoveEvent

公共函數

QDropEvent (const QPointF & pos , Qt::DropActions actions , const QMimeData * data , Qt::MouseButtons buttons , Qt::KeyboardModifiers modifiers , QEvent::Type type = Drop)
void acceptProposedAction ()
Qt::DropAction dropAction () const
Qt::KeyboardModifiers keyboardModifiers () const
const QMimeData * mimeData () const
Qt::MouseButtons mouseButtons () const
QPoint pos () const
const QPointF & posF () const
Qt::DropActions possibleActions () const
Qt::DropAction proposedAction () const
void setDropAction (Qt::DropAction action )
QObject * source () const

詳細描述

當 Widget 接受掉落事件 ,將接收此事件若它有接受最近 QDragEnterEvent or QDragMoveEvent 發送給它的。

掉落事件包含提議動作,可獲取自 proposedAction (),供 Widget 接受或忽略。若可以通過 Widget 處理動作,則應調用 acceptProposedAction () 函數。由於提議動作可以組閤 Qt::DropAction 值,選擇這些值之一作為默認動作或詢問用戶以選擇其首選動作,可能是有用的。

若提議掉落動作不適閤,或許因為自定義 Widget 不支持該動作,可以將其替換為任何 可能掉落動作 通過調用 setDropAction () 采用首選動作。若設置值不存在在按位 OR 組閤的值中,返迴通過 possibleActions (),將使用默認拷貝動作。一旦設置置換掉落動作,就可調用 accept () 而不是 acceptProposedAction () 以完成掉落操作。

The mimeData () 函數提供 Widget 掉落數據,在 QMimeData 對象。這包含數據 MIME 類型的有關信息,除數據本身外。

另請參閱 QMimeData , QDrag ,和 拖放 .

成員函數文檔編製

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

Constructs a drop event of a certain type corresponding to a drop at the point specified by pos in the destination widget's coordinate system.

The actions indicate which types of drag and drop operation can be performed, and the drag data is stored as MIME-encoded data in data .

The states of the mouse buttons and keyboard modifiers at the time of the drop are specified by buttons and modifiers .

void QDropEvent:: acceptProposedAction ()

把拖拽運轉設為提議動作。

另請參閱 setDropAction (), proposedAction (),和 accept ().

Qt::DropAction QDropEvent:: dropAction () const

Returns the action to be performed on the data by the target. This may be different from the action supplied in proposedAction () if you have called setDropAction () to explicitly choose a drop action.

另請參閱 setDropAction ().

Qt::KeyboardModifiers QDropEvent:: keyboardModifiers () const

返迴被按下的修飾符鍵。

const QMimeData *QDropEvent:: mimeData () const

返迴掉落在 Widget 上的數據及其關聯 MIME 類型信息。

Qt::MouseButtons QDropEvent:: mouseButtons () const

Returns the mouse buttons that are pressed..

QPoint QDropEvent:: pos () const

返迴掉落點位置。

const QPointF &QDropEvent:: posF () const

返迴掉落點位置。

Qt::DropActions QDropEvent:: possibleActions () const

返迴可能掉落動作的 OR 組閤。

另請參閱 dropAction ().

Qt::DropAction QDropEvent:: proposedAction () const

返迴提議掉落動作。

另請參閱 dropAction ().

void QDropEvent:: setDropAction ( Qt::DropAction action )

設置 action 以由目標履行數據。使用這以覆蓋 提議動作 采用某一 可能的動作 .

若設置的掉落動作不是可能的動作之一,拖放操作將默認為拷貝操作。

一旦提供置換掉落動作,就可調用 accept () 而不是 acceptProposedAction ().

另請參閱 dropAction ().

QObject *QDropEvent:: source () const

If the source of the drag operation is a widget in this application, this function returns that source; otherwise it returns nullptr . The source of the operation is the first parameter to the QDrag object used instantiate the drag.

This is useful if your widget needs special behavior when dragging to itself.

另請參閱 QDrag::QDrag ().