Results 1 to 4 of 4

Thread: [SOLVED] QByteArray append data in loop "wrong" end size

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Dec 2008
    Location
    Poland
    Posts
    383
    Thanks
    52
    Thanked 42 Times in 42 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Android

    Default [SOLVED] QByteArray append data in loop "wrong" end size

    Hello,
    I have problem with appending dato into QByteArray from another QByteArray.
    What I want to do is do decompress file, zlib, but in my Decompress() function I can only decompress as much as bufferSize (int) data, so I need to divide my compressed size into smaller chunks, not greater then bufferSize.
    I do this as fallows, and I know that probably I should use QDataStram, but for the simplicity sake I use QByteArray.

    Qt Code:
    1. while( !ba.isEmpty() ){
    2.  
    3. QByteArray tmp = ba.left( 262144 );
    4.  
    5. if( ba.size() <= 262144 ){
    6. ba.remove( 0, ba.size() );
    7. }else{
    8. ba.remove( 0, 262144 );
    9. }
    10.  
    11. baUncompre.append( Decompress( tmp ) );
    12.  
    13. }
    To copy to clipboard, switch view to plain text mode 
    Then I write baUncompre to hdd.
    The problem is that baUncompre have wrong size. I know that Decompress() works fine.
    I tried baUncompre .resize( (int)uncompressedSize ); but that resize QBA not to the unompressed size but uncompressedSize +some more.

    Can someone shed some light where is error in my thinking.

    Best regards.

    EDIT: I checked and loop is fine, error is that append appends more then decompressed size or lees (depends if I resize baUncompre or not).

    EDIT: Sorry for garbage post, error was in Decompress() function.
    Last edited by Talei; 29th April 2010 at 16:36. Reason: updated contents

Similar Threads

  1. Replies: 1
    Last Post: 7th April 2010, 21:46
  2. Replies: 3
    Last Post: 25th August 2009, 13:03
  3. Replies: 1
    Last Post: 10th April 2009, 18:07
  4. Translation QFileDialog standart buttons ("Open"/"Save"/"Cancel")
    By victor.yacovlev in forum Qt Programming
    Replies: 4
    Last Post: 24th January 2008, 19:05
  5. How to add a new word to QTextEdit with "append"
    By yagabey in forum Qt Programming
    Replies: 8
    Last Post: 6th January 2008, 11:50

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.