I have two QHash
es, and I want to combine them into one QHash
. Both hashes are of the same type (ie, both are QHash<QString, qint32>
). How do I do this efficiently (and/or Qt-like)?
Something like:
hash1 << hash2;
or
hash1.append( hash2 );
or similar, would be awesome. If that's not possible, I'll just loop through the smaller hash and insert it into the first.
I suppose you are looking for QHash::unite()
.
As stated in the linked documentation:
Inserts all the items in the other hash into this hash. If a key is common to both hashes, the resulting hash will contain the key multiple times.
The unite
function has become obsolete as of Qt 5.15. The best solution is QHash::insert
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With