QWidget::setLayout: Attempting to set QLayout "" on MainWindow "", which already has a layout
<p>I'm making an application in PyQt4 and this is my code so far:</p>

<pre><code>import sys
from PyQt4 import QtGui, QtCore

class MainWindow(QtGui.QMainWindow):

    def __init__(self):
        super(MainWindow, self).__init__()
        self.initUi()

    def initUi(self):
        self.setWindowTitle('Main Menu')
        self.setFixedSize(1200, 625)
        self.firstWidgets()
        self.show()

    def firstWidgets(self):
        self.vbox1 = QtGui.QVBoxLayout()
        self.task1 = QtGui.QLabel('Check 1', self)
        self.task1CB = QtGui.QCheckBox(self)
        self.hbox1 = QtGui.QHBoxLayout()
        self.hbox1.addWidget(self.task1)
        self.hbox1.addWidget(self.task1CB)
        self.vbox1.addLayout(self.hbox1)

        self.setLayout(self.vbox1)


def main():
    application = QtGui.QApplication(sys.argv)
    gui = MainWindow()
    sys.exit(application.exec_())

if __name__=='__main__':
    main()
</code></pre>

<p>My problem is in <code>MainWindow.firstWidgets()</code>. I try to set a layout but I get an error even though that's my first time using <code>.setLayout</code> for that form, which confuses me. </p>

<blockquote>
  <p>QWidget::setLayout: Attempting to set QLayout "" on MainWindow "",
  which already has a layout</p>
</blockquote>