Don't forget that QFile inherits QIODevice:
//
//...Create the output file, etc
//
//first write the ticket
qint64 totalSize = ticket->size();
qint64 chunkSize = 2048; //you can increase it and decrease it as you will
char *readBuffer = new char[chunkSize];
while ( totalSize )
{
if( chunkSize > totalSize )
chunkSize = totalSize;
qint64 actuallyRead = ticket->read( readBuffer, chunkSize );
if( actuallyRead > 0 )
prnFile->write( readBuffer, actuallyRead );
else
break;
totalSize -= actuallyRead;
}
// And when you're done:
delete[] readBuffer;
outPrn.flush();
QFile prnFile;
//
//...Create the output file, etc
//
//first write the ticket
qint64 totalSize = ticket->size();
qint64 chunkSize = 2048; //you can increase it and decrease it as you will
char *readBuffer = new char[chunkSize];
while ( totalSize )
{
if( chunkSize > totalSize )
chunkSize = totalSize;
qint64 actuallyRead = ticket->read( readBuffer, chunkSize );
if( actuallyRead > 0 )
prnFile->write( readBuffer, actuallyRead );
else
break;
totalSize -= actuallyRead;
}
// And when you're done:
delete[] readBuffer;
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
Bookmarks