Skip to content

Instantly share code, notes, and snippets.

View kisuya's full-sized avatar

Jeong kisu kisuya

  • Korea
View GitHub Profile
@kisuya
kisuya / IntToArray.cpp
Created May 10, 2017 05:04
Qt Int to QByteArray for network packet
static inline QByteArray IntToArray(qint32 source) //Use qint32 to ensure that the number have 4 bytes
{
//Avoid use of cast, this is the Qt way to serialize objects
QByteArray temp;
QDataStream data(&temp, QIODevice::ReadWrite);
data << source;
return temp;
}