title: Making elements stretch horizontally in a QScrollArea in PyQT5
body: <p>I'm using <code>Python 3.5</code> and <code>PyQT5</code> and trying to create a window with a list of graphs(using <code>matplotlib</code>). There are enough graphs that the window will need to scroll vertically.</p>
  
  <p>Using <code>QScrollArea</code> it locks the graph sizes in both directions then just scrolls if the window becomes smaller, which leads to whitespace to the right in my use case most times.  Just using a normal <code>QWidget</code>based window lets the graph stretch to fit.</p>
  
  <p>Ideally, I'd like to find a way to let the graphs naturally stretch horizontally to fill space, and remain fixed vertically to enable scrolling.</p>
  
  <p>Here is some simplified code which renders one window with stretching behaviour, and another with the <code>QScrollArea</code> object which stretches in neither direction.</p>
  
  <pre><code>import sys
  import matplotlib
  matplotlib.use("Qt5Agg")
  from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas
  from matplotlib.figure import Figure
  from numpy import arange, sin, pi
  from PyQt5.QtWidgets import QWidget, QApplication, QScrollArea, QGridLayout, QSizePolicy
  
  
  class SimpleGraph(FigureCanvas):
      """Canvas class, which acts as QWidget and renders a sin wave"""
  
      def __init__(self, parent=None, width=5, height=2, dpi=100):
          fig = Figure(figsize=(width, height), dpi=dpi)
          self.axes = fig.add_subplot(111)
          # We want the axes cleared every time plot() is called
          self.axes.hold(False)
  
          t = arange(0.0, 3.0, 0.01)
          s = sin(2 * pi * t)
          self.axes.plot(t, s)
  
          FigureCanvas.__init__(self, fig)
          self.setParent(parent)
  
          FigureCanvas.setSizePolicy(self,
                                     QSizePolicy.Expanding,
                                     QSizePolicy.Expanding)
          FigureCanvas.updateGeometry(self)
  
  
  class NormalWindow(QWidget):
      """Normal window based on Qwidget"""
  
      def __init__(self, width=480, height=320, title="Normal Window", *args, **kwargs):
          super().__init__(*args, **kwargs)
  
          self.setMinimumSize(width, height)
          self.setWindowTitle(title)
          self.show()
  
          grid = QGridLayout()
          grid.addWidget(SimpleGraph())
          grid.addWidget(SimpleGraph())
          grid.addWidget(SimpleGraph())
  
          self.setLayout(grid)
  
  
  class ScrollWindow(QScrollArea):
      """Simple window based on QScrollArea"""
      def __init__(self):
          super().__init__()
  
          graph_list = QWidget()
          grid = QGridLayout()
  
          grid.addWidget(SimpleGraph())
          grid.addWidget(SimpleGraph())
  
          graph_list.setLayout(grid)
  
          self.setWidget(graph_list)
  
          self.setWindowTitle('Scroll Window')
          self.show()
  
  
  app = QApplication(sys.argv)
  window = NormalWindow()
  window2 = ScrollWindow()
  sys.exit(app.exec_())
  </code></pre>