Reputation: 991
Why does the size of QBitArray stay zero? I am using Qt 5.0.2.
QByteArray bytes(4,'b'); // four bytes
QBitArray bits;
QDataStream stream(&bytes, QIODevice::ReadWrite);
stream >> bits;
qDebug() << bytes.size() << bits.size();
Upvotes: 1
Views: 439
Reputation: 5718
When reading from a QDataStream
it expects the data to be in a certain format, as described at http://qt-project.org/doc/qt-5.0/qtcore/datastreamformat.html. In the case of streaming QBitArray
this is:
The array size (quint32) The array bits, i.e. (size + 7)/8 bytes
If this is not the case the operation will fail - you can check QDataStream::status()
to detect errors.
Upvotes: 2