0

I am writing a method to parse a network packet in the form of a QByteArray. It will extract a few values using QDataStream and then hopefully pass the QDataStream along to another method for further processing (to avoid the overhead of making another QDataStream later).

Here is my code:

//datagram is QByteArray
QDataStream ds=new QDataStream(&datagram, QIODevice::ReadOnly);
qint64 someValue = 0;
*ds >> someValue;
emit receivePacket(ds,host, port);

Since I am using signals, passing by reference is not encouraged and since QDataStream is Q_DISABLE_COPY the only option left is to pass by pointer. But if I decide to pass it by pointer, how can I effectively manage the memory? (deleting it only once) later?

Mr. Developerdude
  • 9,118
  • 10
  • 57
  • 95

0 Answers0