本文整理匯總了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)