You can also try:
Qt Code:
  1. quint16 num = 43981; // note that "int" is 4 bytes long and not 2 as in your code
  2. QByteArray byte(2, 0);
  3. qToBigEndian(num, byte.data());
To copy to clipboard, switch view to plain text mode