[Interest] QDataStream not increasing position of QByteArray
Stephan.Ebeling at hs-anhalt.de
Stephan.Ebeling at hs-anhalt.de
Mon Oct 2 14:23:21 CEST 2017
Dear Qt-list-members,
i got the following problem with Qt and i hope that you can help me:
When I write raw network bytes to a QDataStream object repeatedly, the QDataStream never increases the write position of the underlying QByteArray.
Here's the code:
QByteArray recvBuf;
int bytePosition = 0;
void init( ){
recvBuf = QByteArray( 240 * 10, Qt::Uninitiliazed );
}
void receiveAppend( ){
QByteArray buffer( 240, Qt::Uninitialized );
QDataStream datastream( recvBuf, QIODevice::WriteOnly );
datastream.setByteOrder( QDataStream::LittleEndian );
if( udpSocket->readDataGram( buffer.data(), buffer.size(), &ip, &port ){
datastream.device().seek( bytePosition );
datastream.writeRawData( buffer.data(), buffer.size() );
bytePosition += 240;
}
}
Why is this happening?
The code works fine on Linux Mint 18 64Bit. But it's not working on Windows 10 64Bit. I'm using Qt Creator 4.3.1 with Qt 5.9.1.
I appreciate your help.
Best regards
Stephan Ebeling
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20171002/21aacde3/attachment.html>
More information about the Interest
mailing list