0

via a QUdpSocket, I know I'll receive datas which will contain only this struct:

typedef struct myStruct
    {
       int nb_trame;
       std::vector<bool> vBool;
    } myStruct;

but when I receive new datas, I receive a QByteArray right ? So how can I use the received-struct ?

alk
  • 69,737
  • 10
  • 105
  • 255
0xPunt
  • 313
  • 1
  • 4
  • 21

1 Answers1

0

You can't entity-serialize a vector (your way of sending the struct is called entity-serialization). I mean, you can serialize it, but if you attempt to deserialize it this way you will not get a valid object.

You need to implement proper serialization.

SergeyA
  • 61,605
  • 5
  • 78
  • 137
  • So if I use a `bool myTab[20]` instead of my vector, It will be fine ? – 0xPunt May 25 '16 at 13:30
  • @BastienNicolau, entity-serialization is frown upon, and rightfuly so. It is OK in your pet project, but it usually has no place in production application. – SergeyA May 25 '16 at 13:38