Usually, we can drag and drop two things. Data or some graphical objects. If we drag an image from one application to another, we drag and drop binary data. If we drag a tab in Firefox and move it to another place, we drag and drop a graphical component.
dragEnterEvent() ,该函数在用户将一个对象拖(drag)至widget之上时被调用,其参数为QDragEnterEvent类型的指针。请注意下面事件处理函数和事件的区别。
void QWidget::dragEnterEvent(QDragEnterEvent * event)
class PySide.QtGui. QDragEnterEvent ( pos, actions, data, buttons, modifiers ) ¶Parameters: |
|
---|
dropEvent() ,该函数在用户将一个对象拽(drop)至widget之上时被调用,参数为QDropEvent类型的指针
QDrag事件类使用QMimeData类来存储与拖拽操作相关的信息, 下面所谓的action是指在拖放操作的过程中,如果从源对象有mimeData,到了目标对象后,是使用什么action带过来,比如,如果是MoveAction的话,那么源对象应该自己删除自己的。如果是CopyAction,源删不删可以自己根据意图处理。