Linked Questions

Popular Questions

Serialization with QDataStream

Asked by At

I was going through the Serialization using QDataStream and found this gist, SmartStream . But i don't get what is the advantage of this over using QDataStream. Any idea??

Here is the test code I used.

    {
        QByteArray data;
        SmartStream ds(&data, SmartStream::EAccess::eWrite);
        QVariant v(123);
        ds << v;
        data = data.toBase64();
        str = QString(data);
        cout << str.toStdString() << endl;

    }
    {
        QByteArray data = str.toLatin1();
        data = QByteArray::fromBase64(data);
        SmartStream ds(&data, SmartStream::EAccess::eRead);
        QVariant v;
        ds >> v;
        cout << v.toInt() << endl;
    }

Related Questions