How to deep copy QMap and other Qt containers

天大地大妈咪最大 提交于 2019-12-10 03:54:46

问题


Generally speaking, what is the correct way to deep copy Qt containers? I'm not worried about deep copying the containers recursively, although addressing such would be helpful.


回答1:


Despite what everyone will tell you - that you don't deep copy Qt containers - there are situations in which you simply need to perform an actual deep copy instead of just a shallow one. To do that, use detach():

container1 = container2;
container1.detach();


来源:https://stackoverflow.com/questions/16800206/how-to-deep-copy-qmap-and-other-qt-containers

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