Table Of Contents

Previous topic

QDragLeaveEvent

Next topic

QDragMoveEvent

QDropEvent

Inheritance diagram of QDropEvent

Inherited by: QDragMoveEvent, QDragEnterEvent

Synopsis

Functions

Detailed Description

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

When a widget accepts drop events , it will receive this event if it has accepted the most recent PySide.QtGui.QDragEnterEvent or PySide.QtGui.QDragMoveEvent sent to it.

The drop event contains a proposed action, available from PySide.QtGui.QDropEvent.proposedAction() , for the widget to either accept or ignore. If the action can be handled by the widget, you should call the PySide.QtGui.QDropEvent.acceptProposedAction() function. Since the proposed action can be a combination of Qt.DropAction values, it may be useful to either select one of these values as a default action or ask the user to select their preferred action.

If the proposed drop action is not suitable, perhaps because your custom widget does not support that action, you can replace it with any of the possible drop actions by calling PySide.QtGui.QDropEvent.setDropAction() with your preferred action. If you set a value that is not present in the bitwise OR combination of values returned by PySide.QtGui.QDropEvent.possibleActions() , the default copy action will be used. Once a replacement drop action has been set, call PySide.QtCore.QEvent.accept() instead of PySide.QtGui.QDropEvent.acceptProposedAction() to complete the drop operation.

The PySide.QtGui.QDropEvent.mimeData() function provides the data dropped on the widget in a PySide.QtCore.QMimeData object. This contains information about the MIME type of the data in addition to the data itself.

class PySide.QtGui.QDropEvent(pos, actions, data, buttons, modifiers[, type=Drop])
Parameters:
  • actionsPySide.QtCore.Qt.DropActions
  • modifiersPySide.QtCore.Qt.KeyboardModifiers
  • typePySide.QtCore.QEvent.Type
  • dataPySide.QtCore.QMimeData
  • posPySide.QtCore.QPoint
  • buttonsPySide.QtCore.Qt.MouseButtons
PySide.QtGui.QDropEvent.acceptProposedAction()

Sets the drop action to be the proposed action.

PySide.QtGui.QDropEvent.dropAction()
Return type:PySide.QtCore.Qt.DropAction

Returns the action to be performed on the data by the target. This may be different from the action supplied in PySide.QtGui.QDropEvent.proposedAction() if you have called PySide.QtGui.QDropEvent.setDropAction() to explicitly choose a drop action.

PySide.QtGui.QDropEvent.keyboardModifiers()
Return type:PySide.QtCore.Qt.KeyboardModifiers

Returns the modifier keys that are pressed.

PySide.QtGui.QDropEvent.mimeData()
Return type:PySide.QtCore.QMimeData

Returns the data that was dropped on the widget and its associated MIME type information.

PySide.QtGui.QDropEvent.mouseButtons()
Return type:PySide.QtCore.Qt.MouseButtons

Returns the mouse buttons that are pressed..

PySide.QtGui.QDropEvent.pos()
Return type:PySide.QtCore.QPoint

Returns the position where the drop was made.

PySide.QtGui.QDropEvent.possibleActions()
Return type:PySide.QtCore.Qt.DropActions

Returns an OR-combination of possible drop actions.

PySide.QtGui.QDropEvent.proposedAction()
Return type:PySide.QtCore.Qt.DropAction

Returns the proposed drop action.

PySide.QtGui.QDropEvent.setDropAction(action)
Parameters:actionPySide.QtCore.Qt.DropAction
PySide.QtGui.QDropEvent.source()
Return type:PySide.QtGui.QWidget

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 PySide.QtGui.QDrag object used instantiate the drag.

This is useful if your widget needs special behavior when dragging to itself.

See also

QDrag.QDrag()