Serialize / Deserialize QVariantMap with QDataStream between PyQt >> Qt-C++

413 Views Asked by At

I can Successfully Serialize / Deserialize QVariantMap through QDataStream in the PyQt5

Python :

    data = {'mq_username': ('123'),  'np_database': ('png') ,  'category': ('png') ,  'enroll_name': ('png') ,  'notes': ('png') ,   'file': ('png') ,
            'np_database': ('png') , 'PNG-image': (png) }
    v = QVariant(data)
block = QByteArray()
    xout = QDataStream(block, QIODevice.WriteOnly)
    xout.setVersion(qt.QDataStream.Qt_5_10)
    xout << v
    xox = (b'')
    xox = block.data()

This is perfectly fine to deserialize:

out = qt.QDataStream(block, qt.QIODevice.ReadOnly)
        out.setVersion(qt.QDataStream.Qt_5_10)

        keys = out.readQVariant()

I can get all item at keys.

But I can not get it from the C++.

How can I get this QDataStream (QVariantMap) from c++ ?

    QVariantMap *vmat_x;

    QDataStream stream(message);
    stream.setVersion(QDataStream::Qt_5_10);
    stream >> vmat_x ;

vmat_x is always empty

any idea ?

EDIT:

message is QBytearray coming from Python xox

0

There are 0 best solutions below