0

I have a qhash defined with key value pair as QDomElement. as given below. I am trying to update the hash by using const_iterator. But while doing so below error is thrown, how to resolve the same:-

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'

Code Snippet :-

// 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++;
        }
    }
}

Thanks, Priyanka

Priyanka Bhatia
  • 97
  • 2
  • 10

1 Answers1

0

Problem solved, use QHash::iterator pList = hashParentChildList.begin(); instead of QHash::const_iterator pList = hashParentChildList.constBegin();

Priyanka Bhatia
  • 97
  • 2
  • 10