T
T
tfaders2021-11-22 23:37:22
PyQt
tfaders, 2021-11-22 23:37:22

How to insert image on button click in PyQt5?

How to import an image after clicking on a button? I tried doing

def image(self):
    self.lbl = QtWidgets.QLabel(self)
    self.pix = QtGui.QPixmap("image/Rock.png")
    print(self.pix.isNull())
    self.lbl.setPixmap(self.pix)
    self.lbl.resize(400, 400)
    self.lbl.move(30, 1150)

But for some reason the picture is not displayed, what should I do?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question