Results 1 to 7 of 7

Thread: Doubt about deep copy using QByteArray::append() and QByteArray::fromRawData()

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Doubt about deep copy using QByteArray::append() and QByteArray::fromRawData()

    No the two are not equal. If bytesReceived is empty then the first option merely points at the existing buffer and the second immediately makes a copy of the buffer into its own storage. If bytesReceived is not empty at the time of the append() call then both copy the data out of the existing buffer into their own storage.

    Which would be the smartest way of handling this in a embedded development situation,
    That depends entirely on what you intend to do with the bytesReceived QByteArray. You don't tell us, but in your code it is non-const and therefore we assume it will be modified. In that case there will be a deep copy of the original data anyway.

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

    Momergil (9th May 2014)

Similar Threads

  1. Append/Prepend QString to QByteArray
    By ermustaqbal in forum Newbie
    Replies: 5
    Last Post: 2nd August 2011, 07:19
  2. Replies: 1
    Last Post: 22nd June 2011, 08:12
  3. Replies: 3
    Last Post: 29th April 2010, 19:11
  4. [ SOLVED (kinda) ]copy structure to QByteArray
    By pdoria in forum Qt Programming
    Replies: 14
    Last Post: 17th October 2009, 14:42
  5. Replies: 9
    Last Post: 25th July 2009, 13:27

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.