On Monday, 2 October 2017 05:23:21 PDT [email protected] wrote:
> 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.
What write position of a QByteArray? The write position belongs to the
QDataStream, not the array.
> 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 );
This line doesn't compile. I assume you meant
QDataStream datastream( &recvBuf, QIODevice::WriteOnly );
> datastream.setByteOrder( QDataStream::LittleEndian );
>
> if( udpSocket->readDataGram( buffer.data(), buffer.size(), &ip, &port ){
You should try the receiveDatagram() function.
> datastream.device().seek( bytePosition );
datastream.device() here is a QBuffer that QDataStream created internally to
wrap the QByteArray.
> datastream.writeRawData( buffer.data(), buffer.size() );
> bytePosition += 240;
> }
> }
>
>
> Why is this happening?
Why is what happening? What is the issue?
Describe what's happening and what you expected to happen.
--
Thiago Macieira - thiago.macieira (AT) intel.com
Software Architect - Intel Open Source Technology Center
_______________________________________________
Interest mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/interest