All my images are saved into a directory
pictures = '/x.com/user37/Public/....../images/'
I'm trying to load images from that directory onto my GUI screen. This is what I have in my __init__
method.
self.movieimg = QImage()
self.imagelbl = QLabel()
self.imagelbl.setAlignment(Qt.AlignCenter)
self.imagelbl.setPixmap(QPixmap.fromImage(self.movieimg))
When I include, after initializing a QGridLayout
layout.addWidget(self.movieimg, 1, 1)
I get an error saying that argument 1 in addWidget
is an invalid type . Why is this the case?
I created a dictionary entry = { } and I have another function where I call requests
def nextEntry(self)
r= requests.get(self.MOVIES_URL + str(mid))
resp = json.loads(r.content)
img = resp['movie_id']
self.movieimg = QImage(self.movie['img'])
self.imglbl.setPixmap(QPixmap.fromImage(self.movieimg))
Thoughts? Do I need to directly call this function before that statement in the main __init__
function? Thank you!
self.movieimg
is QImage()
type and you need to pass QWidget
type as first argument to addWidget
method. QLabel()
inherits from QWidget
, so try to passing self.imagelbl
instead.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.