Qt

1,十六进制字符串转整型

msgType = datagram.mid(1,1).toHex().toUShort(Q_NULLPTR,16);

msgType为UInt8,在字符串datagrame中位于第1字节,datagrame为QBytearray。

2,十六进制字符串转double

 quint64 longitude = datagram.mid(12,8).toHex().toULongLong(0,16);
    vehInfo.longitude  = *(double*)&longitude;

longitude在字符串中第12字节,大小为8字节。

原文地址:https://www.cnblogs.com/Pan-Z/p/7802769.html