本文整理汇总了Python中PyQt5.QtGui.QDrag.exec方法的典型用法代码示例。如果您正苦于以下问题:Python QDrag.exec方法的具体用法?Python QDrag.exec怎么用?Python QDrag.exec使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtGui.QDrag
的用法示例。
在下文中一共展示了QDrag.exec方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: mouseMoveEvent
# 需要导入模块: from PyQt5.QtGui import QDrag [as 别名]
# 或者: from PyQt5.QtGui.QDrag import exec [as 别名]
def mouseMoveEvent(self, ev):
if (ev.pos() - self.press_pos).manhattanLength() > 16:
# print("drag start")
drag = QDrag(self.controller._gui._window)
# Create the drag thumbnail
if False:
pix = QPixmap(self.tile_rect.width(), self.tile_rect.height())
painter = QPainter(pix)
self.paint(painter, None, None)
painter.end()
drag.setPixmap(pix)
drag.setHotSpot(ev.pos().toPoint() - self.tile_rect.topLeft())
else:
pix = QPixmap("/usr/share/icons/mate/32x32/actions/gtk-dnd-multiple.png").scaled(48, 48)
drag.setPixmap(pix)
if not self.isSelected():
self.controller.clear_selection()
self.setSelected(True)
mime_data = self.controller.selection_to_mimedata(uri_only=True)
drag.setMimeData(mime_data)
# Qt does not allow custom drag actions officially. The
# default drag action value is however carried through
# even if it's invalid, but cursor changes and signals
# like actionChanged() misbehave. The DragWidget class is
# a workaround.
drag_widget = DragWidget(None) # noqa: F841
# this will eat up the mouseReleaseEvent
drag.exec(Qt.CopyAction | Qt.MoveAction | Qt.LinkAction | 0x40, 0x40)