QByteArray buff; memmove(&buff, &tt, sizeof(tt)); udp->write(buff);
udp->write(&tt, sizeof(tt));
QByteArray buff; buff.clear(); buff.resize(56); unsigned char buffer[56] = {0}; memmove(&buffer,(unsigned char *)&tt, 56); for(int i = 0; i <56; i++) buff[i] = buffer[i]; udp->writeDatagram(buff.data(),56,QHostAddress("192.168.0.81"),9800);
C++ (Qt)QByteArray buff;buff.resize(sizeof(tt));memmove(buff.data(), &tt, sizeof(tt));
C++ (Qt)#pragma pack(push, 4)struct MyTT { int member1; ...};#pragma pack(pop)
QByteArray buff;buff.resize(sizeof(tt));memmove(buff.data(), &tt, sizeof(tt));