内容表

上一话题

QDragMoveEvent

下一话题

QEnterEvent

QDropEvent

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

Inheritance diagram of PySide2.QtGui.QDropEvent

继承者: QDragEnterEvent , QDragMoveEvent

详细描述

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

掉落事件包含提议动作,可获得自 proposedAction() , for the widget to either accept or ignore. If the action can be handled by the widget, you should call the acceptProposedAction() function. Since the proposed action can be a combination of DropAction 值,选择这些值之一作为默认动作或询问用户以选择其首选动作,可能是有用的。

若提议掉落动作不适合,或许因为自定义 Widget 不支持该动作,可以将其替换为任何 possible drop actions 通过调用 setDropAction() with your preferred action. If you set a value that is not present in the bitwise OR combination of values returned by possibleActions() , the default copy action will be used. Once a replacement drop action has been set, call accept() 而不是 acceptProposedAction() to complete the drop operation.

mimeData() function provides the data dropped on the widget in a QMimeData 对象。这包含数据 MIME 类型的有关信息,除数据本身外。

class QDropEvent ( pos , actions , data , buttons , modifiers [ , type=Drop ] )
param type

Type

param modifiers

KeyboardModifiers

param actions

DropActions

param buttons

MouseButtons

param pos

QPointF

param data

QMimeData

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 .

PySide2.QtGui.QDropEvent. acceptProposedAction ( )

把拖曳运转设为提议动作。

PySide2.QtGui.QDropEvent. dropAction ( )
返回类型

DropAction

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

PySide2.QtGui.QDropEvent. keyboardModifiers ( )
返回类型

KeyboardModifiers

返回被按下的修饰符键。

PySide2.QtGui.QDropEvent. mimeData ( )
返回类型

QMimeData

返回掉落在 Widget 上的数据及其关联 MIME 类型信息。

PySide2.QtGui.QDropEvent. mouseButtons ( )
返回类型

MouseButtons

Returns the mouse buttons that are pressed..

PySide2.QtGui.QDropEvent. pos ( )
返回类型

QPoint

返回掉落点位置。

PySide2.QtGui.QDropEvent. posF ( )
返回类型

QPointF

返回掉落点位置。

PySide2.QtGui.QDropEvent. possibleActions ( )
返回类型

DropActions

返回可能掉落动作的 OR 组合。

另请参阅

dropAction()

PySide2.QtGui.QDropEvent. proposedAction ( )
返回类型

DropAction

返回提议掉落动作。

另请参阅

dropAction()

PySide2.QtGui.QDropEvent. setDropAction ( action )
参数

action DropAction

设置 action 以由目标履行数据。使用这以覆盖 proposed action 采用某一 possible actions .

若设置的掉落动作不是可能的动作之一,拖放操作将默认为拷贝操作。

一旦提供置换掉落动作,就可调用 accept() 而不是 acceptProposedAction() .

另请参阅

dropAction()

PySide2.QtGui.QDropEvent. source ( )
返回类型

QObject

If the source of the drag operation is a widget in this application, this function returns that source; otherwise it returns None . 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()