PDA

View Full Version : QHash with structure as value



ArkKup
17th February 2014, 18:30
Hi,

I need to create QHash where key will be int and value will be structure but I'm just not sure which way is better to either to keep a pointer to the structure

QHash<int, MyStruct*> myHash;

or keep the structures by value

QHash<int, MyStruct> myHash;

?

anda_skoa
17th February 2014, 19:15
Depends on how expensive your structure is to copy and assign, if you expect the hash to contain a lot of "empty" entries, whether someone getting a copy of the hash should have access to the same objects or not, etc.

Cheers,
_