simplest / best way to fuse several files with QT?
Hi.
I want to create a composite file containing, say, a soundfile and a picturefile, but the main idea is to pile several files of unknown content into one large file... :)
Quite a simple excersise, but I am not quite sure how to use QT (properly) to accomplish this task. QDataStream seems to be the right choice, maybe added with readBytes() / writeBytes().
Anyone care to show me a samle code of how this should be done most elegantly?
thanks!
Havard
Re: simplest / best way to fuse several files with QT?
QDataStream is not the right choice. Use QFile - open one file for writing, one for reading, read all contents and write to the other file, open the second file for reading, etc.
Re: simplest / best way to fuse several files with QT?
using QByteArray QIODevice::readAll () ?
Havard
Re: simplest / best way to fuse several files with QT?
It depends. If you're not afraid files might be very big and put much strain on your computer, then you can use readAll(). Otherwise read a single chunk at a time, for example:
Code:
//...
while(!reading.atEnd()){
buffer = reading.read(1024*1024); //1MB
writing.write(buffer);
}