PySide6.QtWidgets.QGraphicsSceneDragDropEvent

class QGraphicsSceneDragDropEvent

QGraphicsSceneDragDropEvent 类为图形视图框架中的拖放操作提供事件。更多

PySide6.QtWidgets.QGraphicsSceneDragDropEvent 的继承图

概要

方法

注意

本文档可能包含从C++自动翻译到Python的代码片段。我们始终欢迎对代码片段翻译的贡献。如果您发现翻译问题,您也可以通过在我们的https:/bugreports.qt.io/projects/PYSIDE上创建工单来告知我们。

详细描述

QGraphicsView 继承了由 QWidget 提供的拖放功能。当它接收到一个拖放事件时,它会将其转换为 QGraphicsSceneDragDropEvent

QGraphicsSceneDragDropEvent 存储类型为 GraphicsSceneDragEnter、GraphicsSceneDragLeave、GraphicsSceneDragMove 或 GraphicsSceneDrop 的事件。

QGraphicsSceneDragDropEvent 包含鼠标光标在项目、场景和屏幕坐标中的位置;这可以通过 pos()scenePos()screenPos() 来获取。

场景将事件发送到鼠标光标下第一个接受拖放的QGraphicsItem;图形项通过setAcceptDrops()设置为接受拖放。

__init__([type=QEvent.Type.None])
Parameters:

类型Type

acceptProposedAction()

警告

本节包含从C++自动翻译到Python的代码片段,可能包含错误。

将提议的操作设置为已接受,即,将拖放操作设置为提议的操作。这等同于:

setDropAction(proposedAction())

使用此函数时,不应调用accept()

buttons()
Return type:

MouseButton 的组合

返回一个Qt::MouseButtons值,指示生成此鼠标事件时按下了鼠标上的哪些按钮。

另请参阅

MouseButtons

dropAction()
Return type:

DropAction

返回在此拖放操作中执行的动作。这应该由拖放的接收者设置,并由QDrag::exec()返回。

mimeData()
Return type:

QMimeData

此函数返回事件的MIME数据。

modifiers()
Return type:

KeyboardModifier的组合

返回创建拖放事件时按下的键盘修饰键。

另请参阅

KeyboardModifiers

pos()
Return type:

QPointF

返回事件相对于发送事件的视图的鼠标位置。

possibleActions()
Return type:

DropAction的组合

返回拖放操作可能导致的拖放动作。

另请参阅

DropActions

proposedAction()
Return type:

DropAction

返回提议的,即首选的拖放操作。该操作必须是possibleActions()定义的可能操作之一。

另请参阅

possibleActions()

scenePos()
Return type:

QPointF

返回鼠标在场景坐标中的位置。

另请参阅

pos() screenPos()

screenPos()
Return type:

QPoint

返回鼠标相对于屏幕的位置。

另请参阅

pos() scenePos()

setButtons(buttons)
Parameters:

buttonsMouseButton 的组合

setDropAction(action)
Parameters:

动作DropAction

此函数允许拖放操作的接收者设置已执行的拖放操作为action,该操作应为possible actions之一。如果您使用此函数,请调用accept()而不是acceptProposedAction()

setModifiers(modifiers)
Parameters:

修饰符KeyboardModifier 的组合

setPos(pos)
Parameters:

posQPointF

setPossibleActions(actions)
Parameters:

actionsDropAction 的组合

setProposedAction(action)
Parameters:

动作DropAction

setScenePos(pos)
Parameters:

posQPointF

setScreenPos(pos)
Parameters:

posQPoint

source()
Return type:

QWidget

此函数返回创建了QGraphicsSceneDragDropEventQGraphicsView