Dear visitor, welcome to QtForum.org. If this is your first visit here, please read the Help. It explains how this page works. You must be registered before you can use all the page's features. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.
This post has been edited 1 times, last edit by "Nicolas SOUCHON" (May 6th 2008, 3:33pm)
|
|
Source code |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
QByteArray block;
QDataStream out( &block, QIODevice::WriteOnly );
out.setVersion(QDataStream::Qt_4_0);
out << (quint16)0
<< fileName
<< fileSize;
QFile file( "someFile" );
file.open( QIODevice::ReadOnly );
while( ! file.atEnd() )
{
QByteArray arr = file.read( 0x1000 );
block.append( arr );
}
file.close();out.device()->seek(0);
out << (quint16)(block.size() - sizeof(quint16));
|