title: How to make a layout the main widget of a QMainWindow
body: <p>Say I have two buttons, in a horizontal layout, that I need to add to a <code>QMainWindow</code> (basically, an app with a menu bar and two buttons in the main area).</p>
  
  <p>I tried implementing it this way</p>
  
  <pre><code>class Example(QMainWindow):
      def __init__(self):
          super().__init__()
  
          # Menus
          exitAct = QAction(QIcon('exit.png'), '&amp;Exit', self)
          exitAct.setShortcut('Ctrl+Q')
          exitAct.setStatusTip('Exit application')
          exitAct.triggered.connect(qApp.quit)
  
          self.statusBar()
  
          menubar = self.menuBar()
          fileMenu = menubar.addMenu('&amp;File')
          fileMenu.addAction(exitAct)
  
          # central widget
          firstButton = QPushButton("first")
          secondButton = QPushButton("second")
  
          hbox = QHBoxLayout()
          hbox.addWidget(firstButton)
          hbox.addWidget(secondButton)
  
          # Not working because TypeError: setCentralWidget(self, QWidget): argument 1 has unexpected type 'QHBoxLayout'
          # self.setCentralWidget(hbox)
  
          # Not working because centralWidget is not set, therefore is null
          # self.centralWidget().setLayout(hbox)
  
          # Not working because this is a QMainWindow, and the top-level widget already has a layout containing the menu bar for instance
          self.setLayout(hbox)
  
          self.setGeometry(300, 300, 300, 190)
          self.setWindowTitle('Points')
          self.show()
  </code></pre>
  
  <p>I have defined my two buttons, created an horizontal layout and added the buttons to the layout. Now I need to tell my window to use this layout.</p>
  
  <p>However, I cannot manage to add the layout to the <code>QMainWindow</code>, because <code>QMainWindow</code> already has a top level layout (for the menu bar among other things).</p>
  
  <p>As a result, my buttons are not displayed. How can I achieve this ?</p>