Is there a ready-made widget in qt so that a picture from the file is set in it?

  • Do you need the ability to select or display from a file? - ߊߚߤߘ
  • one
    Displaying a picture from a file - Golovanenko Viktor
  • Try a QLabel with HTML markup in the text property: <img src="file:///путь_к_картинке" /> . - ߊߚߤߘ
  • similar question How to insert an image into pyqt5? - jfs

1 answer 1

 #!/usr/bin/env python3 # -*- coding: utf-8 -*- from PyQt5.QtWidgets import QMainWindow, QApplication, QLabel from PyQt5.QtGui import QPixmap class App(QMainWindow): def __init__(self): super().__init__() self.setWindowTitle('Тест') self.setGeometry(200, 200, 300, 300) def load_image(self, file_name): pixmap = QPixmap(file_name) self.label = QLabel(self) self.label.setPixmap(pixmap) self.label.resize(pixmap.width(), pixmap.height()) self.resize(pixmap.width(), pixmap.height()) if __name__ == '__main__': import sys app = QApplication(sys.argv) ex = App() ex.load_image('image.jpg') ex.show() sys.exit(app.exec_())