I am working on some code (part of KDE's kwallet) that stores a QMap as a binary representation, using

QByteArray mapData;
QDataStream ds(&mapData, QIODevice::WriteOnly);
ds << map;

Elsewhere, such binary representations are read back into a QMap using

QByteArray v;
if( !v.isEmpty() ){
    QDataStream ds( &v, QIODevice::ReadOnly );
    ds >> map;

I'd like to modify this so that a text representation is used. I came across a suggestion on a Qt forum that one could use a QTextStream instead of QDataStream. No example solution was given, and when I simply replace the latter by the former function in my code, it won't compile as QMap lacks the corresponding << and >> operators. Am I missing something, or is what I want simply impossible without writing my own parser (for reading back the stored data)?

Related posts

Recent Viewed