我有一个名为能力的QList元素在一个类中,另一个类对象名为k。我想做一个深层复制(this.competence必须是k.competence的深层副本)。 我用一个迭代它:QList <QString>运算符<<
QList< QString>::iterator it;
for( it = k.competence->begin(); it != k.competence->end(); ++it)
{
this.competence << (*it) ;
}
我得到一个错误“敌不过运营商< <”。 问题是每当我尝试这一个循环:
QList< QString>::iterator it;
it = k.competence->begin();
this.competence << *it;
它不给错误。
编辑:使用QList.append议决()方法,而不是运营商< <
抱歉,这并没有多大意义,如果竞争力是列表如何的项目你可以迭代一个项目吗?你应该在此期间迭代列表,为什么你不看看这个答案http://stackoverflow.com/questions/16800206/how-to-deep-copy-qmap-and-other-qt-containers – Marco 2015-02-12 08:53:56
请,总是包含编译器给你的确切的逐字错误。 – ftynse 2015-02-12 09:25:09
谢谢所有人!你真的很有帮助 – 2015-02-12 11:52:20