qtqhash

Using QGraphicsItem as key for QHash


Before I embark into using this datatype and as I am a beginner in Qt, is it possible to use QGraphicsItem as key of QHash? It seems legal to declare something like:

QHash<QGraphicsItem*, someType> hashName;

So I guess it is something allowed.

Thanks.


Solution

  • Yes. But I'd use QMap<QGraphicsItem*, someType>, that doesn't make much difference, though. Also, you can inherit QGraphicsItem to attach data to items.