Kayote
14th November 2015, 13:02
Hi, I am trying to download images so I can show them in a label widget by setting the pixmap.
My code works fine for images with an url that end with an image file type. However, some of the urls are like this: "http://example.com/image.php" on which the content-type header is set to "image/png" and an image is returned, but my code doesn't work in these cases.
This is the code:
QNetworkRequest request(QUrl("http://example.com/image.png"));
manager->get(request);
@slot:
QPixmap image;
image.loadFromData(reply->readAll());
ui->lblPic->setPixmap(image);
Help is appreciated :)
My code works fine for images with an url that end with an image file type. However, some of the urls are like this: "http://example.com/image.php" on which the content-type header is set to "image/png" and an image is returned, but my code doesn't work in these cases.
This is the code:
QNetworkRequest request(QUrl("http://example.com/image.png"));
manager->get(request);
@slot:
QPixmap image;
image.loadFromData(reply->readAll());
ui->lblPic->setPixmap(image);
Help is appreciated :)