Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Serialization for QVector<QPair<size_t, double>>



  • Why isnt it possible to serialize a QVector<QPair<size_t, double>> with QDatastream? I mean i use allowed Datatypes https://doc.qt.io/qt-5/datastreamformat.html .

    Do i need an additional Implementation for that?

    I get this
    Unbenannt.png image url)



  • I tried with the below and it works perfectly. Make sure you have all the relevant includes at the top of your file

    #include <QVector>
    #include <QDataStream>
    #include <QPair>
    #include <QByteArray>
    int main()
    {
    QByteArray temp;
    QVector<QPair<size_t,double> > vect{{5u,2.5},{7u,3.3}};
    QDataStream stream(&temp,QIODevice::WriteOnly);
    stream << vect;
    return 0;
    }
    


  • Oh God i forgot to include QDatastream... thats so emberassing. Solved.


Log in to reply