[Qt-interest] Save in data (image) from QNetworkReply
Thiago Macieira
thiago at kde.org
Mon Dec 6 15:29:18 CET 2010
Em Segunda-feira, 6 de Dezembro de 2010, às 14:49:39, Paul England escreveu:
> // error check
> QByteArray data = reply->readAll();
> QString location = "/path/to/location";
>
> QFile out_file( location );
> out_file.open( QIODevice::WriteOnly );\
> QDataStream stream( &out_file );
> stream << data;
Please read:
http://doc.qt.nokia.com/latest/qdatastream.html#raw
http://doc.qt.nokia.com/latest/datastreamformat.html
The operator<< you called writes more than just the bytes from the network
reply. That's why the image was corrupt.
--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
Senior Product Manager - Nokia, Qt Development Frameworks
PGP/GPG: 0x6EF45358; fingerprint:
E067 918B B660 DBD1 105C 966C 33F5 F005 6EF4 5358
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20101206/617b7010/attachment.bin
More information about the Qt-interest-old
mailing list