Results 1 to 7 of 7

Thread: QByteArray data manuplation.

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Nov 2010
    Posts
    100
    Thanks
    38
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4

    Default QByteArray data manuplation.

    hello frenz, i am having a small problem i am not able to figure out how to remove first 12 Chars from a QByteArray and append the next 40 chars into another byte array or string.
    something like i have to remove the first 6 bytes 03b702200001 and then append the next 20 bytes 00de00de00de00de00de00de00de00de00de00de00de00de00 de00de00de00de00de00de00de00de and so on to the next line of data also i tried using .remove(); but i cud't get it right.

    Qt Code:
    1. 03b702200001 00de00de00de00de00de00de00de00de00de00de00de00de00de00de00de00de00de00de00de00de
    2. 03b702200002 00de00de00de00de00de00de00de00de00de00de00de00de00de00de00de00de00de00de00de00de
    3. 03b702200003 00de00de00de00de00de00de00de00de00de00de00de00de00de00de00de00de00de00de00de00de
    4. 03b702200004 00 de00de00de00de00de00de00de00de00de00de00de00de00de00de00de00de00de00de00de00de
    To copy to clipboard, switch view to plain text mode 

    i am getting continuous data from rs232 terminal which i am pushing to a QByteArray this is what i did to remove the first 12 characters and append the next 40 characters .
    Qt Code:
    1. for(int i=12; i< datstr.size(); i++)
    2. {
    3. newdat.append(datstr.at(i));
    4. bytecount++
    5.  
    6. if(bytecount==40)
    7. {
    8. newdat.remove(0,12);
    9. bytecount=0;
    10. }
    11. }
    12. textBrowser->append(newdat);
    13. datstr.clear();
    To copy to clipboard, switch view to plain text mode 
    i am not able to think about a exact logic to do this.
    Last edited by nagabathula; 1st December 2010 at 16:26.

Similar Threads

  1. Replies: 3
    Last Post: 29th April 2010, 19:11
  2. inver data from QByteArray
    By aj2903 in forum Qt Programming
    Replies: 2
    Last Post: 16th January 2010, 07:56
  3. Replies: 9
    Last Post: 25th July 2009, 13:27
  4. Corrupt JPEG data: premature end of data segment
    By node_ex in forum Qt Programming
    Replies: 1
    Last Post: 19th August 2008, 08:57
  5. QByteArray with network data
    By merlvingian in forum Qt Programming
    Replies: 1
    Last Post: 1st June 2007, 17:53

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.