The reason I'm using it is because my lecturer told me to. He also said that QDataStream would automatically pad bits for QBitArray in order to make up a whole byte.
The reason I'm using it is because my lecturer told me to. He also said that QDataStream would automatically pad bits for QBitArray in order to make up a whole byte.
To write "raw" data to a QDataStream you must use "writeRawData". Otherwise, the data written is only readable by another instance of QDataStream.
Ask him why he did that then. It's not a correct approach.
Doesn't it defeat the purpose of using huffman code? Besides, your lecturer is wrong.He also said that QDataStream would automatically pad bits for QBitArray in order to make up a whole byte.
If you write a four bit array to data stream, 40 bits will be written to the device. And no padding is there, actually. The superflous bits are just ignored, from what I see.Qt Code:
{ quint32 len = ba.size(); out << len; if (len > 0) out.writeRawData(ba.d.constData() + 1, ba.d.size() - 1); return out; }To copy to clipboard, switch view to plain text mode
Bookmarks