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