def METHOD_NAME(self, ev):
    image = self.viewer.image()
    painter = QPainter(self)
    if self.size() == image.size():
        painter.drawImage(ev.rect(), image, ev.rect())
    else:
        s = image.size()
        s.scale(self.size(), Qt.KeepAspectRatio)
        r = QRect()
        r.setSize(s)
        r.moveCenter(self.rect().center())
        painter.drawPixmap(r, self.viewer.pixmap(s))