在学习 QHash 并将 QHash 序列化为 DataStream 时,我收到以下代码错误。
typedef QHash <quint32,QString> hashtype1;
typedef QHash <QLocale::Language,hashtype1> hashtype;
hashtype1 hash;
hash.insert(1, "Key1");
hash.insert(2, "Key2");
hashtype hash1;
hash1.insert(QLocale::English, hash);
hash1.insert(QLocale::French, hash);
QByteArray ba;
QByteArray ba1;
QDataStream ds(&ba, QIODevice::ReadWrite);
QDataStream ds1(&ba1, QIODevice::ReadWrite);
ds << hash;
ds1 << hash1;
qDebug() << ds.device()->readAll();
ds.device()->reset();
ds1.device()->reset();
hashtype1 hashcopy;
ds >> hashcopy;
hashtype hash1copy;
ds1 >> hash1copy;
最后一条语句给出一个错误,说 /usr/include/qt4/QtCore/qdatastream.h:362: error: no match for 'operator>>' in 'in >> k'</p>
我无法纠正这个..我做错了吗?我该如何纠正?