title: How to remove a QVBoxLayout from a QWidget or convert it to a QGridLayout?
body: <p>I am trying to do some modifications to a GUI. My GUI is built on a QWidget. Initially I had just a QPushButton in the QWidget which then got deleted and was replaced by a QGridlayout housing a bunch of other stuff. Now I want to initially have two buttons held in a QVBoxLayout which get deleted and the QVBoxLayout gets deleted and/or replaced with the QGridLayout which then houses the next items.</p>
  
  <p>The problem: I can't delete and/or replace the QVBosLayout with the QGridLayout.</p>
  
  <p>Minimal reproducible example below. You need PyQt5 to run</p>
  
  <pre><code>from PyQt5 import QtCore, QtGui, QtWidgets
  
  
  class Ui_Form():
  
      def __init__(self):
          self.nCode_analysis_set_up = QtWidgets.QWidget()
          self.nCode_analysis_set_up.resize(300, 100)
          self.nCode_analysis_set_up.setWindowFlags(self.nCode_analysis_set_up.windowFlags() | QtCore.Qt.MSWindowsFixedSizeDialogHint)
          self.nCode_analysis_set_up.setWindowTitle("nCode analysis set-up")
          self.Box = QtWidgets.QVBoxLayout(self.nCode_analysis_set_up)
          self.importButton = QtWidgets.QPushButton(self.nCode_analysis_set_up)
          self.importButton.setText("Open import model")
          self.importButton.clicked.connect(self.input_model)
          self.Box.addWidget(self.importButton)
  
      def input_model(self):
          self.importButton.deleteLater()
          self.Box.deleteLater()
          self.Box = QtWidgets.QGridLayout(self.nCode_analysis_set_up)
          self.analysis_type_label = QtWidgets.QLabel(self.nCode_analysis_set_up)
  
  if __name__ == "__main__":
      import sys
      app = QtWidgets.QApplication(sys.argv)
      ui = Ui_Form()
      ui.nCode_analysis_set_up.show()
      sys.exit(app.exec_())
  </code></pre>