Set pixmap of label from web image, is it possible?



  • Can you set the pixmap of a label from eg this url?
    @http://cdn.shuffleos.com/wp-content/uploads/2011/09/wallch-unity-quicklist.png@

    The other way is to wget the image and then set as pixmap, but i would like to know if it is possible without downloading it...



  • Not directly AFAIK.
    You could request image with QNetworkAccessManager:get(...), connect QNetworkReply::finished() signal to your slot in which you will call QNetworkReply::ReadAll() and pass resulting QByteArray to QPixmap::loadFromData(...). It seems better then calling external programs to download image for you.



  • So with what you say the image is been downloaded right?
    Ok sure it's a better way, but i would like to know if it is possible without downloading..



  • How would you like to open image (or any other file by that matter) from the web if you don't download it byte by byte first? How would you know what are its contents?
    Even if it looks like images are loaded directly from the web, image has to be downloaded before opening (or loaded progressively in case of few file types). In case of QNetworkAccessManager method you don't have to save tmp file.
    Depending on size of file you want to open, memory usage can go quite high.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.