Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Serialization for QVector<QPair<size_t, double>>

Serialization for QVector<QPair<size_t, double>>

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 300 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Fuel 0F Offline
    Fuel 0F Offline
    Fuel 0
    wrote on last edited by
    #1

    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)

    1 Reply Last reply
    0
    • VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by
      #2

      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;
      }
      

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      1 Reply Last reply
      5
      • Fuel 0F Offline
        Fuel 0F Offline
        Fuel 0
        wrote on last edited by
        #3

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

        1 Reply Last reply
        1

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved