我必須用不同的數據填充QByteArray
。所以我使用QDataStream
。追加一個QByteArray到QDataStream?
QByteArray buffer;
QDataStream stream(&buffer, QIODevice::WriteOnly);
qint8 dataHex= 0x04;
qint8 dataChar = 'V';
stream << dataHex<< dataChar;
qDebug() << buffer.toHex(); // "0456" This is what I want
但是,我也想追加一個QByteArray到buffer
。
QByteArray buffer;
QDataStream stream(&buffer, QIODevice::WriteOnly);
qint8 dataHex= 0x04;
qint8 dataChar = 'V';
QByteArray moreData = QByteArray::fromHex("ff");
stream << dataHex<< dataChar << moreData.data(); // char * QByteArray::data()
qDebug() << buffer.toHex(); // "045600000002ff00" I would like "0456ff"
我在想什麼?