A QPixmap can be used to show an image in a PyQT window. QPixmap() can load an image, as parameter it has the filename. To show the image, add the QPixmap to a QLabel.
QPixmap supports all the major image formats: BMP,GIF,JPG,JPEG,PNG,PBM,PGM,PPM,XBM and XPM.
Related Course: Create GUI Apps with Python PyQt5
PyQT image
QPixmap
Start by creating a QPixmap and a QLabel. Then you can combine them like this:
1 | self.im = QPixmap("./image.jpg") |
Then add the whole thing to a layout, like a QGridLayout
1 | self.grid = QGridLayout() |
Example
Copy and paste the code below to load an image from your local computer. The image will be shown in a grid layout.
1 | import sys |
If you are new to Python PyQt, then I highly recommend this book.