Well, maybe, but the QMap<> base class for my CClassColorMap class is fully specialized. My QDataStream operators use my derived class, not QMap<>. Even if I provided a set of QDataStream operators for a fully specialized QMap<>, that still is not the same as the operators for my own class. If I had additional data members in my class that I wanted to serialize, operators for a fully specialized QMap<> wouldn't know about them.maybe you should provide an explicit template specialization for this to work.
I think this is a defect in the lookup system for the QDataStream operators used in QMetaType. I haven't tried this with classes derived from other Qt base classes (like QString, f.e.) but my hunch is the same thing would happen. I'm under deadline pressure and unfortunately don't have the time to investigate.
Edit: OK, I threw my deadline out the window and tested this using a class derived from QString. Everything I said above is completely wrong. At first, I thought that my string class QDataStream operators were not being called, so I changed the derived class to be a top level class with a QString member. The operators still weren't called. Huh?
Then I realized that on import if QSettings doesn't find a value with the key you are asking for, it doesn't call operator>>() because there is nothing to serialize. When I exited the program (and saved the QSettings back out to the file), the operator<<() was called. I changed my string class back to being derived from QString, and sure enough, it works now on import too, because now there's a key in the QSettings file.
I did the same for my QMap<> class - turned it back into a derived class of QMap<>, and it works now too. To make sure, I manually deleted all of the relevant entries from the QSettings file. On import, the operator>>() is not called, but on export operator<<() is called as it is supposed to be.
My bad. Jumped to a wrong conclusion and because I was doing everything in the debugger and exiting before the export to the QSettings file occurred, I assumed a defect.
I apologize for wasting everyone's time chasing a wrong conclusion.
Bookmarks