本文整理汇总了Python中PyQt5.Qt.QDrag.exec_方法的典型用法代码示例。如果您正苦于以下问题:Python QDrag.exec_方法的具体用法?Python QDrag.exec_怎么用?Python QDrag.exec_使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.Qt.QDrag
的用法示例。
在下文中一共展示了QDrag.exec_方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: mouseMoveEvent
# 需要导入模块: from PyQt5.Qt import QDrag [as 别名]
# 或者: from PyQt5.Qt.QDrag import exec_ [as 别名]
def mouseMoveEvent(self, event):
dex = self.indexAt(event.pos())
if dex.isValid():
self.setCursor(Qt.PointingHandCursor)
else:
self.unsetCursor()
if not event.buttons() & Qt.LeftButton:
return
if self.in_drag_drop or not dex.isValid():
QTreeView.mouseMoveEvent(self, event)
return
# Must deal with odd case where the node being dragged is 'virtual',
# created to form a hierarchy. We can't really drag this node, but in
# addition we can't allow drag recognition to notice going over some
# other node and grabbing that one. So we set in_drag_drop to prevent
# this from happening, turning it off when the user lifts the button.
self.in_drag_drop = True
if not self._model.flags(dex) & Qt.ItemIsDragEnabled:
QTreeView.mouseMoveEvent(self, event)
return
md = self._model.mimeData([dex])
pixmap = dex.data(DRAG_IMAGE_ROLE).pixmap(self.iconSize())
drag = QDrag(self)
drag.setPixmap(pixmap)
drag.setMimeData(md)
if self._model.is_in_user_category(dex):
drag.exec_(Qt.CopyAction|Qt.MoveAction, Qt.CopyAction)
else:
drag.exec_(Qt.CopyAction)