How about something like this:
QHash<QString, QVariant> entries;
entries.insert("key1", 1);
entries.insert("key2", "seven");
entries.insert("key3", 22.7);
QFile fileOut
("hashtest.dat");
{
out << entries;
fileOut.flush();
fileOut.close();
}
QHash<QString, QVariant> inputs;
QFile fileIn
("hashtest.dat");
{
in >> inputs;
fileIn.close();
}
QHash<QString, QVariant> entries;
entries.insert("key1", 1);
entries.insert("key2", "seven");
entries.insert("key3", 22.7);
QFile fileOut("hashtest.dat");
if (fileOut.open(QIODevice::WriteOnly))
{
QDataStream out(&fileOut);
out.setVersion(QDataStream::Qt_4_6);
out << entries;
fileOut.flush();
fileOut.close();
}
QHash<QString, QVariant> inputs;
QFile fileIn("hashtest.dat");
if (fileIn.open(QIODevice::ReadOnly))
{
QDataStream in(&fileIn);
in.setVersion(QDataStream::Qt_4_6);
in >> inputs;
fileIn.close();
}
To copy to clipboard, switch view to plain text mode
Bookmarks