本文整理汇总了Python中PyQt5.QtWidgets.QTreeWidget.dropEvent方法的典型用法代码示例。如果您正苦于以下问题:Python QTreeWidget.dropEvent方法的具体用法?Python QTreeWidget.dropEvent怎么用?Python QTreeWidget.dropEvent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtWidgets.QTreeWidget
的用法示例。
在下文中一共展示了QTreeWidget.dropEvent方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: dropEvent
# 需要导入模块: from PyQt5.QtWidgets import QTreeWidget [as 别名]
# 或者: from PyQt5.QtWidgets.QTreeWidget import dropEvent [as 别名]
def dropEvent(self, event: QDropEvent):
"""custom drop event to prevent reparenting
"""
# data = event.mimeData()
# if data.hasFormat('application/x-qabstractitemmodeldatalist'):
# the_bytearray = data.data('application/x-qabstractitemmodeldatalist')
# data_item = self.decodeMimeData(the_bytearray)
# print("got a drop event", data_item)
# item Drop above
pos = event.pos()
dest_item = self.itemAt(pos)
if dest_item is None:
return
dest_parent = dest_item.parent()
selected_items = self.selectedItems()
for x in selected_items:
if x.parent() != dest_parent:
return
res = QTreeWidget.dropEvent(self, event)
if isinstance(dest_item, OutlineVirtualHelixItem):
part = dest_item.part()
vhi_list = [dest_parent.child(i) for i in range(dest_parent.childCount())]
part.setImportedVHelixOrder([vhi.idNum() for vhi in vhi_list], check_batch=False)