title: Resizing a window with PyQT5 - how do I reduce the size of a widget to allow the window to be shrunk?
body: <p>I'm trying to learn it by re-making an old command line C program I've got for working with pixel art.</p>
  <p>At the moment, the main window starts as a single QLabel set to show a 300 x 300 scaled up version of a 10 x 10 white image.</p>
  <p>I'm using the resizeEvent (I've also tried using paintEvent with the same problem) to rescale the image to fill the window as the window size is increased.</p>
  <p>My question is, how do I rescale the image to fit in the window as the window size is decreased? As it stands, the window can't be resized smaller than the widget displaying the image. Essentially, I can make the window (and image) bigger, but never smaller.</p>
  <p>My code for this so far is below. As it stands it's only working based on changes to window width, just to keep it simple while I'm working this out. Is there a way to allow the window to be resized to be smaller than the largest widget? Or is there a better way to approach this problem?</p>
  <pre><code>#Create white 10*10 image
  image = QImage(10,10,QImage.Format.Format_ARGB32)
  image_scaled = QImage()
  image.fill(QColor(255,255,255)) 
  
  class Window(QMainWindow):
      
      #scale image to change in window width (image is window width * window width square)
      def resizeEvent(self,event):
          if self.imageLabel.width()&gt;self.imageLabel.height(): 
              self.image_scaled = image.scaled(self.imageLabel.width(),self.imageLabel.width()) 
              self.pixmap = QPixmap.fromImage(self.image_scaled)
              self.imageLabel.setPixmap(self.pixmap)  
          QWidget.resizeEvent(self, event)
  
      def __init__(self, parent=None):
          super().__init__(parent)
          self.setGeometry(100,100,300,300)   
          self.imageLabel = QLabel()
          self.setCentralWidget(self.imageLabel)
          
          self.image_scaled = image.scaled(self.imageLabel.width(),self.imageLabel.width()) 
          self.pixmap = QPixmap.fromImage(self.image_scaled)
          self.imageLabel.setPixmap(self.pixmap)  
  
  
  app = QApplication(sys.argv)
  win = Window()
  win.show()
  sys.exit(app.exec_())
  </code></pre>