[Qt-interest] Save in data (image) from QNetworkReply

Paul England pengland at cmt-asia.com
Mon Dec 6 14:49:39 CET 2010


I'm getting various images in the form for a QNetworkReply.
I've tried a few methods, all of which have caveats. 

QImage::save() requires the JPEG plugin which I've not got set up,
and doesn't allow for other data types it may not support.  As I'm doing
no editing of these images, it's not really necessary.

Second try was to use a QDataStream().  It's downloading the images,
but they are "broken".  Nothing will view them.

Code

void my_dialog::reply_finished( QNetworkReply* reply )
{
    // 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;
    out_file.close();  
}

Images are there, but broken. :(
Am I doing something wrong?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20101206/770cfc8a/attachment.html 


More information about the Qt-interest-old mailing list