Good day. There is some multistage program in which QT and C ++ modules are used interchangeably. In the function of the deepest level, an array of source_array [6] is formed. It returns to the function one level up, in the form of a pointer.

char* catched_array= handler(in_array); QByteArray array_to_send; 

I see that everything is transmitted correctly, the catched array contains the data that I need. Now I need to convert it to QByteArray, and there is a problem here. Append, a simple constructor, fromRawData either zeroes the array to be converted, or garbage is written to the QByteArray I need. I tried to insert, but then the values ​​in catched_array are changed to some kind of left. What could be the problem?

  • and here so tried QByteArray a(catched_array, 6); - KoVadim
  • @KoVadim tried, catched_array all vanished. It seems that the pointer jumps somewhere in the empty memory area or is lost ... - Taras Kolesko
  • one
    and what's inside the handler? malloc or just a pointer to a local array inside a function? - KoVadim
  • You were right, you had to do malloc. There was just a pointer to a local array inside the function, and that was the point. - Taras Kolesko
  • then do not forget to release the memory. - KoVadim

0