QDataStream and QByteArray as a buffer
Can you explain why this code:
- int main(int argc, char *argv[])
- {
- QByteArray buffer;
- data.insert( "123", "qwe" );
- qDebug() << "Data:" << data;
- stream << data;
- qDebug() << "Buffer's size:" << buffer.size();
- data.clear();
- stream >> data;
- qDebug() << "Data:" << data;
- qDebug() << "Buffer's size:" << buffer.size();
- qDebug() << "Buffer:" << buffer.toHex();
- }
gives this output:
- Buffer's size: 21
- Data: QHash()
- Buffer's size: 21
- Buffer: "000000010000000600310032003300000003717765"
As i can understand from http://doc.qt.nokia.com/stable/datastreamformat.html streaming from data to buffer is correct (the last line of the output). But why then there is no streaming from buffer to data?
4 replies
You must log in to post a reply. Not a member yet? Register here!



