1

I have a function read (that takes and returns void), which stores data from a file into a QHash<QString,QHash<QString,QString> > -- for clarity, let's call any QHash fitting this template hash. My aim was to make a "master" list of all the hashes that exist, which would be a QHash<QHash<QString,QHash<QString,QString> > > -- let's call this masterHash. Within read, everything is fine: masterHash["hash1"] and hash1 are identical.

I have another function write (that takes a QString of the form"hash1" and returns void), which stores data from masterHash["hash1"] to a file. Now, this was my aim in creating masterHash in the first place -- to access hash1 from "hash1". Within write, hash1 still contains the things that were stored in read, but masterHash["hash1"] is now empty (though masterHash still contains the key "hash1").

What am I doing wrong or missing? There is no QHash dereferencing anywhere. (Originally, I didn't even store to hash1, but I was trying to figure out why masterHash["hash1"] wasn't saving.)

Alternately, is there a better way to achieve the same goal (pointing to a hash using a string of its name)?

user3329769
  • 31
  • 1
  • 3
  • 1
    `QHash > >` is missing the key (QString?). Add some minimal code, it's hard to follow and hard to judge what's going on without code. Note that if you insert hash1 into masterhash and then modify hash1, masterhash will be unaffected, as the value inserted is always a copy, not a reference to the original value. – Frank Osterfeld Apr 12 '14 at 09:08
  • I agree with Frank about it. This is a typical example when code is worth of many words. It is a bit weird to describe code with only text on this low-level. – László Papp Apr 12 '14 at 09:32

0 Answers0