fromRawData这个函数转换。官方描述是这样
Constructs a QByteArray that uses the first size bytes of the data array. The bytes are not copied. The QByteArray will contain the data pointer. The caller guarantees that data will not be deleted or modified as long as this QByteArray and any copies of it exist that have not been modified. In other words, because QByteArray is an implicitly shared class and the instance returned by this function contains the data pointer, the caller must not delete data or modify it directly as long as the returned QByteArray and any copies exist. However, QByteArray does not take ownership of data, so the QByteArraydestructor will never delete the raw data, even when the last QByteArray referring to data is destroyed.
调用者不能直接删除数据或修改它只要返回QByteArray和任何副本的存在
配合这次出现的问题,意思是说,队列中的地址还是转换前的data的地址,所以会出现队列中的数据出错。
解决的办法:
用QByteArray的构造函数把char*转成QByteArray.因为是深复制。所以队列的数据的地址不会是char*时的地址。
总结:遇到问题,要多debug.单步跟踪。看出错的数据产生的变化,这样更好定位。