Results 1 to 14 of 14

Thread: Concatenating two binary files

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Concatenating two binary files

    Don't forget that QFile inherits QIODevice:

    Qt Code:
    1. QFile prnFile;
    2. //
    3. //...Create the output file, etc
    4. //
    5.  
    6. //first write the ticket
    7. qint64 totalSize = ticket->size();
    8. qint64 chunkSize = 2048; //you can increase it and decrease it as you will
    9.  
    10. char *readBuffer = new char[chunkSize];
    11. while ( totalSize )
    12. {
    13. if( chunkSize > totalSize )
    14. chunkSize = totalSize;
    15. qint64 actuallyRead = ticket->read( readBuffer, chunkSize );
    16.  
    17. if( actuallyRead > 0 )
    18. prnFile->write( readBuffer, actuallyRead );
    19. else
    20. break;
    21.  
    22. totalSize -= actuallyRead;
    23. }
    24. // And when you're done:
    25. delete[] readBuffer;
    26. outPrn.flush();
    To copy to clipboard, switch view to plain text mode 
    This is only to write the ticket.
    After this you can write the same code to write the pdf file( you must use the same output file, and to make sure, position the file pointer at the end of the file ). Or you can make it a function and call it twice.

    For more information you can check QIODevice class description.
    Feel free to ask if you have any other questions...

    Regards
    Last edited by marcel; 20th April 2007 at 17:36. Reason: took something out of while loop :)

Similar Threads

  1. Replies: 5
    Last Post: 22nd September 2006, 08:04
  2. UTF-16 files
    By jcr in forum Qt Programming
    Replies: 3
    Last Post: 7th September 2006, 12:43
  3. [Win32/VC++ 8.0] Strange problems with qrc_*.cpp files
    By mloskot in forum Installation and Deployment
    Replies: 6
    Last Post: 6th March 2006, 10:28
  4. Visual Studio 2003 and .vcproj files
    By mbjerkne in forum General Discussion
    Replies: 2
    Last Post: 1st February 2006, 00:51
  5. xml with binary question
    By TheKedge in forum Qt Programming
    Replies: 7
    Last Post: 12th January 2006, 23:21

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.