PeterThePuter
17th December 2010, 18:36
Hey all,
I am having some trouble serializing a QHash. Following this snippit (http://qt.onyou.ch/2010/10/19/62/) I attempted this:
#include <QtCore/QCoreApplication>
#include <QHash>
#include <QVariant>
#include <QDebug>
int main(int argc, char *argv[])
{
QHash<QString,QVariant> hash;
hash.insert("Key1",1);
hash.insert("Key2","thing2");
QByteArray ba;
QDataStream ds(&ba, QIODevice::WriteOnly);
ds << hash;
qDebug() << ds;
}
However, when I run it, qDebug() spits this out:
QIODevice::read: WriteOnly device
QIODevice::read: WriteOnly device
QIODevice::read: WriteOnly device
QVariant(, )
What am I doing wrong?
Thanks!
-J
I am having some trouble serializing a QHash. Following this snippit (http://qt.onyou.ch/2010/10/19/62/) I attempted this:
#include <QtCore/QCoreApplication>
#include <QHash>
#include <QVariant>
#include <QDebug>
int main(int argc, char *argv[])
{
QHash<QString,QVariant> hash;
hash.insert("Key1",1);
hash.insert("Key2","thing2");
QByteArray ba;
QDataStream ds(&ba, QIODevice::WriteOnly);
ds << hash;
qDebug() << ds;
}
However, when I run it, qDebug() spits this out:
QIODevice::read: WriteOnly device
QIODevice::read: WriteOnly device
QIODevice::read: WriteOnly device
QVariant(, )
What am I doing wrong?
Thanks!
-J