QTreeview with my model how to implement copy paste operation

扶醉桌前 提交于 2019-12-11 09:51:07

问题


I want to implement copy and paste operation in my QTreeView against my context menu copy and paste I have subclass QAbstractItemModel. I have Treeview Say Four Tope level items and each of them are having multiple child

Top Item1


----------


     Child1
           Child11
                 Child111




Top Item2


----------


Top Item3

I want to right on click item "child1" and copy child1 and all its child up to child111 and then right click and paste on "Top Item3" so that all items from child1 to child111 is copied under Top Item3.


回答1:


After pressing copy you should store pointer to Child1. After pasting to Top Item Tree3 you create new child in it and copy contents of Child1 to new child. This should be done recursively.



来源:https://stackoverflow.com/questions/11735791/qtreeview-with-my-model-how-to-implement-copy-paste-operation

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