Results 1 to 5 of 5

Thread: Parsing/extracting from a binary QByteArray

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    3
    Thanked 453 Times in 435 Posts
    Wiki edits
    15

    Default Re: Parsing/extracting from a binary QByteArray

    This will work assuming that the hardware platfrom and data chunk have same endian. If hardware platfrom and data chunk have different endian you are looking at a different problem. Endian mismatch will for sure cause degrade in performance.


    This is just plain C style, nothing much of C++


    Qt Code:
    1. struct Record
    2. {
    3. quint32 Long1;
    4. quint32 Long2;
    5. quint32 Long3;
    6. quint32 Long4;
    7. quint16 Short1;
    8. quint16 Short2;
    9. //...
    10. };
    11.  
    12.  
    13. const Record *record = (const Record*)chunk.constData();
    14. quint32 long_data1 = record->Long1;
    15. quint32 long_data2 = record->Long2;
    16. quint16 short_data1 = record->Short1;
    To copy to clipboard, switch view to plain text mode 
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

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

    Phlucious (2nd December 2011)

Similar Threads

  1. Replies: 1
    Last Post: 22nd June 2011, 08:12
  2. Extracting int values from QByteArray
    By Tottish in forum Newbie
    Replies: 4
    Last Post: 7th April 2010, 10:41
  3. Replies: 1
    Last Post: 20th January 2010, 09:01
  4. Replies: 9
    Last Post: 25th July 2009, 13:27
  5. Extracting xml fragment from QXmlStreamReader
    By Gopala Krishna in forum Qt Programming
    Replies: 5
    Last Post: 1st December 2007, 09:14

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.