Results 1 to 7 of 7

Thread: QDataStream extra bytes in output?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jul 2007
    Posts
    27
    Thanks
    10
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QDataStream extra bytes in output?

    OK, I've fixed it without getting rid of the data stream.

    I was doing this before (for some reason this injects garbage out):

    This is in the server code...
    Qt Code:
    1. outDataStream << (quint16)0;
    2. outDataStream << "<< ";
    3. outDataStream << output;
    4. outDataStream << (quint16)(outByteArray.size() - sizeof(quint16));
    To copy to clipboard, switch view to plain text mode 

    And now I'm doing this, instead (this works fine):
    Qt Code:
    1. outDataStream << (quint16)0;
    2. outDataStream << "<< " + output;
    3. outDataStream << (quint16)(outByteArray.size() - sizeof(quint16));
    To copy to clipboard, switch view to plain text mode 

    I'm not sure what the real difference is, but the second one works flawlessly.

    Thanks for all your help.

    Gordon E.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QDataStream extra bytes in output?

    The difference is that in the first case you send two strings, not one, and each of them is serialized separately.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.