[Interest] QDatastream, QMap, QImage serialization

Jason H jhihn at gmx.com
Wed May 16 22:51:39 CEST 2018


I'm trying to write a GUI utility to provide a simple UI. I'm wanting a no-frills database of several Qt types, and I'm trying to use QVariantMap for that. It's going well except that QImages aren't being serialized correctly. Yes, I know there is a QVariant limitation with "GUI types" ( http://doc.qt.io/qt-5/qvariant.html#a-note-on-gui-types ) however QImage has an operator QVariant(). I was expecting to see pixel data get stored in the file, but it's just being stored as an empty QString. So it seems that QDataStream can't serialize a QImage? I know that's not true, so it looks like QDataStream can't serialize a QVariant that is a QImage. I think that's what I'm running into. I would expect some QByteArray fall-back, but the bytes aren't making it to disk. It would be ok for me if I had to manually convert the image later from an opaque byte array, so long as it was written and read properly.

What's the best way to accomplish this serialization?

Many thanks!



More information about the Interest mailing list