def paintEvent(self, event):
"""
Overrides the QLabel method. Shouldn't need to be called directly.
"""
super().paintEvent(event)
if self._pixmap_src is None:
return
self._pixmap = self._pixmap_src.scaled(
self.size(), QtCore.Qt.KeepAspectRatio)
x = (self.width() - self._pixmap.width())/2
y = (self.height() - self._pixmap.height())/2
painter = QtGui.QPainter(self)
painter.drawPixmap(x, y, self._pixmap)
评论列表
文章目录