问题描述
我想针对上下文菜单复制和粘贴在QTreeView中实现复制和粘贴操作,我有子类QAbstractItemModel。我有Treeview说四个Tope级项目,每个项目都有多个孩子
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
我要右键单击项目 child1,然后将child1及其所有子级复制到child111,然后右键单击并粘贴
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.
推荐答案
在按复制后,您应存储在顶部Item3上,以便将所有从child1到child111的项目都复制到顶部Item3下。指向Child1的指针。粘贴到Top Item Tree3之后,您将在其中创建新的子代,并将Child1的内容复制到新的子代。这应该递归完成。
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.
这篇关于QTreeview用我的模型如何实现复制粘贴操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!