title: (PyQt) QVBoxLayout shrink upon multiple loading of addWidget
body: <p>Why is the layout shrinking like this and other times going back to normal?</p>
  
  <p><a href="https://i.stack.imgur.com/SJVeH.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SJVeH.gif" alt="enter image description here"></a></p>
  
  <p>I've created several separate UI files in QtDesigner, one is the MainWindow and the other is a widget for Loading Data. </p>
  
  <p>In order to work with these files, I've created separate child classes of each UI file. In order to add a new widget to the MainWindow I've created a <code>addWidget()</code> function; it works by adding a particular widget to the scrollarea layout. You can see this function in <code>MainWindow.py</code></p>
  
  <p><hr></p>
  
  <h2>Here is the code for <code>__main__.py</code></h2>
  
  <pre><code>import multiprocessing as mp
  import os.path
  import sys
  import time
  
  from PyQt5 import QtGui
  from PyQt5 import QtWidgets
  from PyQt5.QtCore import *
  from PyQt5.QtGui import QPixmap
  from PyQt5.QtWidgets import *
  
  from point_spectra_gui.future_.functions import *
  from point_spectra_gui.future_.util import delete
  from point_spectra_gui.future_.util.excepthook import my_exception_hook
  
  
  def new():
      p = mp.Process(target=main, args=())
      p.start()
  
  
  def connectWidgets(ui):
      ui.actionLoad_Data.triggered.connect(lambda: ui.addWidget(LoadData.Ui_Form))
  
  
  def main():
      sys._excepthook = sys.excepthook
      sys.excepthook = my_exception_hook
  
      app = QtWidgets.QApplication(sys.argv)
      mainWindow = QtWidgets.QMainWindow()
      ui = MainWindow.Ui_MainWindow()
      ui.setupUi(mainWindow)
      connectWidgets(ui)
      mainWindow.show()
      sys.exit(app.exec_())
  
  
  if __name__ == '__main__':
      main()
  </code></pre>
  
  <p><hr></p>
  
  <h2>Here is the code for <code>MainWindow.py</code></h2>
  
  <pre><code>from PyQt5 import QtWidgets
  
  from point_spectra_gui.future_.functions import *
  from point_spectra_gui.future_.util import *
  from point_spectra_gui.ui import MainWindow
  
  
  class Ui_MainWindow(MainWindow.Ui_MainWindow):
      def setupUi(self, MainWindow):
          self.MainWindow = MainWindow
          super().setupUi(MainWindow)  # Run the basic window UI
          self.menu_item_shortcuts()  # set up the shortcuts
  
      def addWidget(self, object):
          widget = object()
          widget.setupUi(self.scrollArea)
          self.widgetLayout = QtWidgets.QVBoxLayout()
          self.widgetLayout.setObjectName("widgetLayout")
          self.verticalLayout_3.addLayout(self.widgetLayout)
          self.widgetLayout.addWidget(widget.get_widget())
  
      def menu_item_shortcuts(self):
          self.actionExit.setShortcut("ctrl+Q")
          self.actionCreate_New_Workflow.setShortcut("ctrl+N")
          self.actionOpen_Workflow.setShortcut("ctrl+O")
          self.actionRestore_Workflow.setShortcut("ctrl+R")
          self.actionSave_Current_Workflow.setShortcut("ctrl+S")
  </code></pre>
  
  <p><hr></p>
  
  <h2>Here is the code of the child class <code>LoadData.py</code></h2>
  
  <pre><code>from PyQt5 import QtWidgets
  
  from point_spectra_gui.ui.LoadData import Ui_loadData
  
  
  class Ui_Form(Ui_loadData):
      def setupUi(self, Form):
          super().setupUi(Form)
          self.connectWidgets()
  
      def get_widget(self):
          return self.groupBox
  
      def connectWidgets(self):
          self.newFilePushButton.clicked.connect(lambda: self.on_getDataButton_clicked())
          # self.get_data_line_edit.textChanged.connect(lambda: self.get_data_params())
          # self.dataname.textChanged.connect(lambda: self.get_data_params())
  
      def on_getDataButton_clicked(self):
          filename, _filter = QtWidgets.QFileDialog.getOpenFileName(None, "Open Data File", '.', "(*.csv)")
          self.fileNameLineEdit.setText(filename)
          if self.fileNameLineEdit.text() == "":
              self.fileNameLineEdit.setText("*.csv")
  </code></pre>
  
  <p><hr></p>
  
  <h2>**Edit</h2>
  
  <p>Upon trying this again and then <strong>shrinking</strong> the window. The layout goes back to normal.
  This to me tells me it's not a problem with my code, it's the way the Qt handles the adding of widgets. I still do not understand why this is happening though. So any insight into how this is happening is very much appreciated. </p>
  
  <p><a href="https://i.stack.imgur.com/KWYss.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KWYss.gif" alt="enter image description here"></a></p>