Results 1 to 5 of 5

Thread: Serialized QByteArray length

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    6
    Thanked 348 Times in 333 Posts

    Default Re: Serialized QByteArray length

    It could be 1 byte.

    If your array will be less than 255 characters then send 1 byte for the length.
    If your array will be less than 65535 characters then send 2 bytes for the length and ensure you have 2 bytes before assuming you have the length.
    etc.

  2. The following user says thank you to squidge for this useful post:

    giantdragon (21st May 2011)

  3. #2
    Join Date
    Jan 2011
    Posts
    34
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    6

    Default Re: Serialized QByteArray length

    Quote Originally Posted by squidge View Post
    It could be 1 byte.

    If your array will be less than 255 characters then send 1 byte for the length.
    If your array will be less than 65535 characters then send 2 bytes for the length and ensure you have 2 bytes before assuming you have the length.
    etc.
    Thanks.
    I think it will be better to send always 32-bit interger (qint32) and check bytesAvailable >= 4.

Similar Threads

  1. length of Plotmarker lines
    By FelixB in forum Qwt
    Replies: 2
    Last Post: 12th October 2010, 13:57
  2. Is it possible to set a maximum length for QTextEdit ???
    By vairamuthu.g in forum Qt Programming
    Replies: 1
    Last Post: 28th August 2010, 06:17
  3. Set Maximum Length of QTextEdit
    By moh.gup@gmail.com in forum Qt Programming
    Replies: 3
    Last Post: 2nd July 2010, 09:27
  4. Replies: 9
    Last Post: 25th July 2009, 14:27
  5. qt4 & xp - QTextEdit length
    By incapacitant in forum Newbie
    Replies: 4
    Last Post: 6th March 2006, 16:34

Tags for this Thread

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.