0

There are 4 ways to view Images in PyQt5.

First way: QLabel, QPixmap

label = QLabel(self)
pixmap = QtGui.QPixmap("landscape.jpg")
label.setPixmap(pixmap)
label.setGeometry(500,300,650,493)

Second way: QPainter, drawImage

painter = QPainter(self)
target = QRect(500,300,650,493)
source = QRect(0,0,650,493)
image = QImage("landscape.jpg")
painter.drawImage(target,image,source)

Third way: QPainter, drawPicture (however, this gives me an 'Incorrect header' error)

painter = QPainter(self)
picture = QPicture()
picture.load("landscape.jpg")
painter.drawPicture(0,0,picture)

Fourth way: QPainter, drawPixmap

painter = QPainter(self)
target = QRect(500,300,650,493)
source = QRect(0,0,650,493)
pixmap = QPixmap("landscape.jpg")
painter.drawPixmap(target,pixmap,source)

This leaves me very puzzled and very very confused. Which of these ways should I use to get the highest quality of Images and geometric figures both on video and in print?

Nepura
  • 125
  • 10

0 Answers0