'Scale and translate the image to fit within rect (must be a QRect or QRectF).'

def setRect(self, rect):

    self.resetTransform()
    self.translate(rect.left(), rect.top())
    self.scale((rect.width() / self.width()), (rect.height() / self.height()))
