how to use QPtrDict in C++/Qt?
Hey,
I built a QPtrDict with QString as keys, and an object as value (irrelevant what kind of object). I know I filled the dictionary correctly because I can iterate it with a QPtrDictIterator and I see the correct content. My problem is I can't extract a value out of it by using a key, I think I'm doing someting wrong...
This is how I fill the dictionary:
exts.insert( new QString(ext), new ExtDescr(ext, descr, icon, open, casesensitive));
where exts is declared as:
QPtrDict<ExtDescr> exts;
and ext is a QString. If I just put ext instead of new QString(ext), I get an error from gcc: invalid conversion from const *void to *void
I try to get the value like this:
ExtDescr *extDescr = exts[ new QString(getFileExtension(fi)) ];
but ExtDescr is always null.
The documentation says the keys must be void pointer but I do not quite understand what that means, and how I can correctly use them. If anybody would know how to use a QPtrDict, I'd be very grateful!
|