QHash::const_iterator pList = hashParentChildList.constBegin()
我有一个定义为QDomElement的键值对的qhash。如下所示。我试图通过使用const_iterator来更新哈希值。但是,当这样做下面的错误抛出,如何解决相同的:-
error C2664: 'erase' : cannot convert parameter 1 from 'class QHash<class QDomElement,class QDomElement>::const_iterator' to 'class QHash<class QDomElement,class QDomElemen
t>::iterator'
代码片段:-
// update parent child mapping hash
QHash<QDomElement, QDomElement>::const_iterator pList = hashParentChildList.constBegin();
while (pList != hashParentChildList.constEnd())
{
if(pList.key() == element)
{
pList = hashParentChildList.erase(pList); // Error Line
}
else
{
pList++;
}
}
}
谢谢,要不是
问题解决,使用QHash:迭代器pList = hashParentChildList.begin();而不是