本文整理汇总了Python中PyQt5.QtGui.QDrag.target方法的典型用法代码示例。如果您正苦于以下问题:Python QDrag.target方法的具体用法?Python QDrag.target怎么用?Python QDrag.target使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtGui.QDrag
的用法示例。
在下文中一共展示了QDrag.target方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: mouseMoveEvent
# 需要导入模块: from PyQt5.QtGui import QDrag [as 别名]
# 或者: from PyQt5.QtGui.QDrag import target [as 别名]
def mouseMoveEvent(self, evt):
"""
Protected method to handle mouse move events.
@param evt reference to the event (QMouseEvent)
"""
if self.__model is None:
super(E5ModelMenu, self).mouseMoveEvent(evt)
return
if not (evt.buttons() & Qt.LeftButton):
super(E5ModelMenu, self).mouseMoveEvent(evt)
return
manhattanLength = (evt.pos() -
self.__dragStartPosition).manhattanLength()
if manhattanLength <= QApplication.startDragDistance():
super(E5ModelMenu, self).mouseMoveEvent(evt)
return
act = self.actionAt(self.__dragStartPosition)
if act is None:
super(E5ModelMenu, self).mouseMoveEvent(evt)
return
idx = self.index(act)
if not idx.isValid():
super(E5ModelMenu, self).mouseMoveEvent(evt)
return
drag = QDrag(self)
drag.setMimeData(self.__model.mimeData([idx]))
actionRect = self.actionGeometry(act)
if qVersion() >= "5.0.0":
drag.setPixmap(self.grab(actionRect))
else:
drag.setPixmap(QPixmap.grabWidget(self, actionRect))
if drag.exec_() == Qt.MoveAction:
row = idx.row()
if self.__dropIndex == idx.parent() and self.__dropRow <= row:
row += 1
self.__model.removeRow(row, self.__root)
if not self.isAncestorOf(drag.target()):
self.close()
else:
self.aboutToShow.emit()