How to decode “application/x-qabstractitemmodeldatalist” in Qt for drag and drop?

前端 未结 3 1496
醉梦人生
醉梦人生 2020-12-10 03:48

I\'ve created a child class of QTreeWidget that I want to be able to drag items from another tree widget too (I want to handle the insertion myself though), as well as from

3条回答
  •  一整个雨季
    2020-12-10 04:17

    In PySide2 this works for me

    def dropEvent(self, event):
        if event.mimeData().hasFormat('application/x-qabstractitemmodeldatalist'):
            data = event.mimeData()
            source_item = QtGui.QStandardItemModel()
            source_item.dropMimeData(data, QtCore.Qt.CopyAction, 0,0, QtCore.QModelIndex())
            print(source_item.item(0, 0).text()) 
    

提交回复
热议问题