qt: pyqt: QTreeView internal drag and drop almost working… dragged item disappears

空扰寡人 提交于 2019-11-30 23:47:36

This doesn't solve all the problems, but changing dropMimeData() to the following will at least allow moving leaf items.

    self.beginInsertRows(parentIndex, row, row)
    parentIndex.internalPointer().add_child_obj(Branch(item.get_name(), item.get_value(), parent), row)
    self.endInsertRows()

A drag-drop operation is effectively two steps, an insert (done in dropMimeData) and a remove (done automatically by the Move drag operation). The changes above insert a new item rather than trying to insert an item which is already in the model and which will be removed from the old location after the insert occurs.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!