PyQt - Set QLabel image from URL
pyqt, python
Solution
`QImage.load` takes a filename, not the image data. If you want to do that, you need to use `QImage.loadFromData`.
Problem
I've been trying to set an image to a QLabel from a URL. But im having no luck. Here is how im trying to do it right now: ``` import urllib, cStringIO img_file = cStringIO.StringIO(urllib.urlopen(image_url).read()) image_file = Image.open(img_file) ``` Then setting this to a QImage: ``` final_image = QImage(image_file) self.emit(SIGNAL("finished(QImage)"), final_image ) ``` The image is getting passed back from a thread to a method in the main GUI. ``` def set_image(self, final_image): self.main_picture_pixmap = QPixmap.fromImage(final_image).scaled( QSize(self.picture_label.size()), Qt.KeepAspectRatio, Qt.FastTransformation ) self.picture_label.setPixmap(self.main_picture_pixmap) ``` Doing this I get the error: ``` QPixmap::scaled: Pixmap is a null pixmap ``` Is there anyway to fix this, or a different way to do this?