内容表

上一话题

QGraphicsSceneContextMenuEvent

下一话题

QGraphicsSceneEvent

QGraphicsSceneDragDropEvent

QGraphicsSceneDragDropEvent class provides events for drag and drop in the graphics view framework. 更多

Inheritance diagram of PySide2.QtWidgets.QGraphicsSceneDragDropEvent

概要

详细描述

QGraphicsView inherits the drag and drop functionality provided by QWidget . When it receives a drag and drop event, it translates it to a QGraphicsSceneDragDropEvent .

QGraphicsSceneDragDropEvent stores events of type GraphicsSceneDragEnter , GraphicsSceneDragLeave , GraphicsSceneDragMove ,或 GraphicsSceneDrop .

QGraphicsSceneDragDropEvent contains the position of the mouse cursor in both item, scene, and screen coordinates; this can be retrieved with pos() , scenePos() ,和 screenPos() .

The scene sends the event to the first QGraphicsItem under the mouse cursor that accepts drops; a graphics item is set to accept drops with setAcceptDrops() .

class QGraphicsSceneDragDropEvent ( [ type=None ] )
param type

Type

构造新 QGraphicsSceneDragDropEvent 的指定 type . The type can be either GraphicsSceneDragEnter , GraphicsSceneDragLeave , GraphicsSceneDragMove ,或 GraphicsSceneDrop .

PySide2.QtWidgets.QGraphicsSceneDragDropEvent. acceptProposedAction ( )

Sets the proposed action as accepted, i.e, the drop action is set to the proposed action. This is equal to:

setDropAction(proposedAction())
											

When using this function, one should not call accept() .

PySide2.QtWidgets.QGraphicsSceneDragDropEvent. buttons ( )
返回类型

MouseButtons

返回 MouseButtons value indicating which buttons were pressed on the mouse when this mouse event was generated.

另请参阅

MouseButtons

PySide2.QtWidgets.QGraphicsSceneDragDropEvent. dropAction ( )
返回类型

DropAction

Returns the action that was performed in this drag and drop. This should be set by the receiver of the drop and is returned by exec() .

PySide2.QtWidgets.QGraphicsSceneDragDropEvent. mimeData ( )
返回类型

QMimeData

This function returns the MIME data of the event.

PySide2.QtWidgets.QGraphicsSceneDragDropEvent. modifiers ( )
返回类型

KeyboardModifiers

Returns the keyboard modifiers that were pressed when the drag and drop event was created.

另请参阅

KeyboardModifiers

PySide2.QtWidgets.QGraphicsSceneDragDropEvent. pos ( )
返回类型

QPointF

Returns the mouse position of the event relative to the view that sent the event.

PySide2.QtWidgets.QGraphicsSceneDragDropEvent. possibleActions ( )
返回类型

DropActions

Returns the possible drop actions that the drag and drop can result in.

另请参阅

DropActions

PySide2.QtWidgets.QGraphicsSceneDragDropEvent. proposedAction ( )
返回类型

DropAction

Returns the drop action that is proposed, i.e., preferred. The action must be one of the possible actions as defined by possibleActions() .

另请参阅

DropAction possibleActions()

PySide2.QtWidgets.QGraphicsSceneDragDropEvent. scenePos ( )
返回类型

QPointF

Returns the position of the mouse in scene coordinates.

PySide2.QtWidgets.QGraphicsSceneDragDropEvent. screenPos ( )
返回类型

QPoint

Returns the position of the mouse relative to the screen.

PySide2.QtWidgets.QGraphicsSceneDragDropEvent. setButtons ( buttons )
参数

buttons MouseButtons

Sets the mouse buttons that were pressed when the event was created to buttons .

另请参阅

MouseButtons buttons()

PySide2.QtWidgets.QGraphicsSceneDragDropEvent. setDropAction ( action )
参数

action DropAction

This function lets the receiver of the drop set the drop action that was performed to action , which should be one of the possible actions 。调用 accept() in stead of acceptProposedAction() if you use this function.

PySide2.QtWidgets.QGraphicsSceneDragDropEvent. setModifiers ( modifiers )
参数

modifiers KeyboardModifiers

Sets the keyboard modifiers that were pressed when the event was created to modifiers .

另请参阅

KeyboardModifiers modifiers()

PySide2.QtWidgets.QGraphicsSceneDragDropEvent. setPos ( pos )
参数

pos QPointF

Sets the position of the mouse to pos ; this should be relative to the widget that generated the event, which normally is a QGraphicsView .

另请参阅

pos() setScenePos()setScreenPos()

PySide2.QtWidgets.QGraphicsSceneDragDropEvent. setPossibleActions ( actions )
参数

actions DropActions

Sets the possible drop actions that the drag can result in to actions .

另请参阅

DropActions possibleActions()

PySide2.QtWidgets.QGraphicsSceneDragDropEvent. setProposedAction ( action )
参数

action DropAction

Sets the proposed action to action . The proposed action is a DropAction that is one of the possible actions as given by possibleActions() .

PySide2.QtWidgets.QGraphicsSceneDragDropEvent. setScenePos ( pos )
参数

pos QPointF

Sets the scene position of the mouse to pos .

另请参阅

scenePos() setScreenPos()setPos()

PySide2.QtWidgets.QGraphicsSceneDragDropEvent. setScreenPos ( pos )
参数

pos QPoint

Sets the mouse position relative to the screen to pos .

另请参阅

screenPos() setScenePos()setPos()

PySide2.QtWidgets.QGraphicsSceneDragDropEvent. source ( )
返回类型

QWidget

This function returns the QGraphicsView that created the QGraphicsSceneDragDropEvent .