QDropEvent 类

QDropEvent class provides an event which is sent when a drag and drop action is completed. 更多...

头: #include <QDropEvent>
qmake: QT += gui
继承: QEvent
继承者:

QDragMoveEvent

公共函数

QDropEvent (const QPointF & pos , Qt::DropActions actions , const QMimeData * data , Qt::MouseButtons buttons , Qt::KeyboardModifiers modifiers , 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

额外继承成员

详细描述

QDropEvent class provides an event which is sent when a drag and drop action is completed.

当 Widget 接受掉落事件 ,将接收此事件若它有接受最近 QDragEnterEvent or QDragMoveEvent 发送给它的。

掉落事件包含提议动作,可获取自 proposedAction (),供 Widget 接受或忽略。若可以通过 Widget 处理动作,则应调用 acceptProposedAction () 函数。由于提议动作可以组合 Qt::DropAction 值,选择这些值之一作为默认动作或询问用户以选择其首选动作,可能是有用的。

若提议掉落动作不适合,或许因为自定义 Widget 不支持该动作,可以将其替换为任何 可能掉落动作 通过调用 setDropAction () 采用首选动作。若设置值不存在在按位 OR 组合的值中,返回通过 possibleActions (),将使用默认拷贝动作。一旦设置置换掉落动作,就可调用 accept () 而不是 acceptProposedAction () 以完成掉落操作。

mimeData () 函数提供 Widget 掉落数据,在 QMimeData 对象。这包含数据 MIME 类型的有关信息,除数据本身外。

另请参阅 QMimeData , QDrag ,和 拖放 .

成员函数文档编制

QDropEvent:: QDropEvent (const QPointF & pos , Qt::DropActions actions , const QMimeData * data , Qt::MouseButtons buttons , Qt::KeyboardModifiers modifiers , 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.

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

返回被按下的鼠标按钮。

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 0. 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 ().