一个写操作可以参考:
QDataStream &operator >>(QDataStream &in, SerializedMessage &message) { qint32 type; qint32 dataLength; QByteArray dataArray; in >> type >> dataLength; dataArray.resize(dataLength); // <-- You need to add this line. int bytesRead = in.readRawData(dataArray.data(), dataLength); // Rest of function goes here. }
时间: 2024-12-21 23:41:11