PySide6.QtWidgets.QGraphicsSceneDragDropEvent¶
- class QGraphicsSceneDragDropEvent¶
QGraphicsSceneDragDropEvent
类为图形视图框架中的拖放操作提供事件。更多…概要¶
方法¶
def
__init__()
def
buttons()
def
dropAction()
def
mimeData()
def
modifiers()
def
pos()
def
proposedAction()
def
scenePos()
def
screenPos()
def
setButtons()
def
setDropAction()
def
setModifiers()
def
setPos()
def
setScenePos()
def
setScreenPos()
def
source()
注意
本文档可能包含从C++自动翻译到Python的代码片段。我们始终欢迎对代码片段翻译的贡献。如果您发现翻译问题,您也可以通过在我们的https:/bugreports.qt.io/projects/PYSIDE上创建工单来告知我们。
详细描述¶
QGraphicsView
继承了由QWidget
提供的拖放功能。当它接收到一个拖放事件时,它会将其转换为QGraphicsSceneDragDropEvent
。QGraphicsSceneDragDropEvent
存储类型为 GraphicsSceneDragEnter、GraphicsSceneDragLeave、GraphicsSceneDragMove 或 GraphicsSceneDrop 的事件。QGraphicsSceneDragDropEvent
包含鼠标光标在项目、场景和屏幕坐标中的位置;这可以通过pos()
、scenePos()
和screenPos()
来获取。场景将事件发送到鼠标光标下第一个接受拖放的
QGraphicsItem
;图形项通过setAcceptDrops()
设置为接受拖放。- acceptProposedAction()¶
警告
本节包含从C++自动翻译到Python的代码片段,可能包含错误。
将提议的操作设置为已接受,即,将拖放操作设置为提议的操作。这等同于:
setDropAction(proposedAction())
使用此函数时,不应调用
accept()
。- buttons()¶
- Return type:
MouseButton
的组合
返回一个Qt::MouseButtons值,指示生成此鼠标事件时按下了鼠标上的哪些按钮。
另请参阅
MouseButtons
- dropAction()¶
- Return type:
返回在此拖放操作中执行的动作。这应该由拖放的接收者设置,并由QDrag::exec()返回。
此函数返回事件的MIME数据。
- modifiers()¶
- Return type:
返回创建拖放事件时按下的键盘修饰键。
另请参阅
KeyboardModifiers
返回事件相对于发送事件的视图的鼠标位置。
- possibleActions()¶
- Return type:
DropAction
的组合
返回拖放操作可能导致的拖放动作。
另请参阅
DropActions
- proposedAction()¶
- Return type:
返回提议的,即首选的拖放操作。该操作必须是
possibleActions()
定义的可能操作之一。另请参阅
返回鼠标在场景坐标中的位置。
另请参阅
返回鼠标相对于屏幕的位置。
另请参阅
- setButtons(buttons)¶
- Parameters:
buttons –
MouseButton
的组合
- setDropAction(action)¶
- Parameters:
动作 –
DropAction
此函数允许拖放操作的接收者设置已执行的拖放操作为
action
,该操作应为possible actions
之一。如果您使用此函数,请调用accept()
而不是acceptProposedAction()
。- setModifiers(modifiers)¶
- Parameters:
修饰符 –
KeyboardModifier
的组合
- setPossibleActions(actions)¶
- Parameters:
actions –
DropAction
的组合
- setProposedAction(action)¶
- Parameters:
动作 –
DropAction
此函数返回创建了
QGraphicsSceneDragDropEvent
的QGraphicsView
。