PDA

View Full Version : QHash



coderbob
2nd July 2008, 12:08
Is there a special way to manipulate a QDomElement so I can use it as an index in a QHash?


QHash<QDomElement, QTreeWidgetItem *> itemFromElement;


Chokes with no candidates. In the docs I see a qHash ( const T * key ) but it escapes me how to make QDomElement work in this case.

Bob

ChristianEhrlicher
2nd July 2008, 14:27
You must provide a function "qHash ( const QDomElement * key )" and return a proper value for each DomElement.

caduel
2nd July 2008, 14:29
QHash<QDomElement, QTreeWidgetItem *> itemFromElement;
Well, a QDomElement is no pointer, so that does not help you here. (This function just means that you can hash any pointer types.)

If you want to hash QDomElements (do you really need to?), you must provide a function

uint qHash(const QDomElement&);

A possible (not nec. good) way would be to transform all the relevant stuff of a QDomElement into a QString and hash that.

I suggest to think hard about if you really need/want to hash QDomElements.
Tell us why you want to do it. Perhaps we find a different solution.

HTH