hi
please point the error in the following code
Qt Code:
QDataStream stream; stream<<(qint32)12345; qint32 i; stream>>i; qDebug()<<i<<" i";To copy to clipboard, switch view to plain text mode
the output is
i expect the output to be 12345.
hi
please point the error in the following code
Qt Code:
QDataStream stream; stream<<(qint32)12345; qint32 i; stream>>i; qDebug()<<i<<" i";To copy to clipboard, switch view to plain text mode
the output is
i expect the output to be 12345.
You have no QIODevice set.
You should see a warning in the debug output about this/: "QDataStream: No device".
The data stream must be created with a QIODevice either by passing it in the constructor or via setDevice.
thanks marcel
but even after constructing a QDataStream that operates on QByteArray i am getting the same output
heres the code
Qt Code:
QByteArray ar; stream<<(qint32)12345; qint32 i; stream>>i; qDebug()<<i<<" i";To copy to clipboard, switch view to plain text mode
the output is
It's a stream. Streams don't work like that. You will have to seek the underlying device to beginning, just like in this other thread of yours.
J-P Nurmi
babu198649 (21st December 2007)
thanks jpn
it worked after using this statement
how to copy one QDataStream to another QDataStream.
Last edited by babu198649; 21st December 2007 at 11:47.
Bookmarks