title: Stretch the widgets properly in a horizontal layout of pyqt5
body: <p>I tried to setup a main window, with a central widget. This contains a general widget and a label for help messages.</p>
  <p>I wanted a stretch of 4:1. The base widget should get 4 times the space of the help label. But it seems both get the half of the window.</p>
  <p>Here's my code:</p>
  <pre class="lang-py prettyprint-override"><code>import sys
  from PyQt5.QtWidgets import \
      QApplication, QMainWindow, QWidget, QStatusBar, QMenuBar, QMenu, \
      QAction, QHBoxLayout, QLabel
  
  from PyQt5.QtCore import QRect, QMetaObject, QCoreApplication
  
  
  class UISimple(QMainWindow):
      def __init__(self, title=&quot;stretch 4 parts to 1&quot;):
          super().__init__()
  
          self.showMaximized()
          self.setWindowTitle(title)
  
          # FIXME: is that necessary?
          self.centralwidget = QWidget(self)
          self.setCentralWidget(self.centralwidget)
  
          self.hlayout = QHBoxLayout(self.centralwidget)
  
          # Widget as a container for further views
          self.widget_container = QWidget(self.centralwidget)
          self.hlayout.addWidget(self.widget_container)
  
          # label for show some help
          self.label_help = QLabel(self.centralwidget)
          self.label_help.setStyleSheet(&quot;background-color: #B9E9BE&quot;)
          self.hlayout.addWidget(self.label_help)
  
          # FIXME: label 1 and widget 4 parts of the window.
          self.hlayout.setStretch(4, 1)
  
          self.setLayout(self.hlayout)
  
      def setup(self):
          self._setup_main_window()
  
      def write_help(self, helptext):
          self.label_help.setText(helptext)
  
  
  if __name__ == '__main__':
  
      app = QApplication(sys.argv)
      window = UISimple()
      window.write_help(&quot;You need some help - so i'm in trouble!&quot;)
      sys.exit(app.exec_())
  
  </code></pre>