title: Space is added to the layout even if nothing was added
body: <p>I have been designing a PySide6 Application but the problem is that even if I have not added any space to the layout the layout still contains a lot of visible space.</p>
  <p><a href="https://i.stack.imgur.com/TvGeg.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TvGeg.png" alt="Updated Screenshot" /></a></p>
  <p>Debug Screenshot with widget borders as red:
  <a href="https://i.stack.imgur.com/kqBlp.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kqBlp.png" alt="Updated Screenshot" /></a></p>
  <p>Is there anyway to remove the space? Here is the code:</p>
  <pre class="lang-py prettyprint-override"><code>from PySide6 import QtCore
  from PySide6.QtWidgets import (
      QMainWindow,
      QVBoxLayout,
      QFormLayout,
      QWidget,
      QApplication,
      QLabel,
      QCheckBox,
      QHBoxLayout,
      QLineEdit,
      QFileDialog,
      QPushButton
  )
  import os
  import sys
  
  
  class Styler_Py(QMainWindow):
      def __init__(self, parent=None) -&gt; None:
          super().__init__(parent)
  
          # Window Setup
          self.setWindowTitle(&quot;PyStyler&quot;)
  
          # Layout setup        
          self.container_widget = QWidget()
          self.main_layout = QVBoxLayout()
          self.container_widget.setLayout(self.main_layout)
          self.setCentralWidget(self.container_widget)
  
          # Irrelevant code here
  
          # --- New Section ---
          self.main_layout.addSpacing(10)
          self.main_layout.addStretch()
          # --- New Section ---
  
          # Files
          self.files_label = QLabel(&quot;&lt;h3&gt;Files&lt;/h3&gt;&quot;)  # Note for the future, the closure tag did not have forward slash and have been fixed using an answer below
          self.main_layout.addWidget(self.files_label)
          self.files_layout = QVBoxLayout()
          self.main_layout.addLayout(self.files_layout)
  
          # Files -&gt; Input File
          self.input_file = FileInput()
          self.input_file_layout = QHBoxLayout()
          self.files_layout.addLayout(self.input_file_layout)
          self.input_file_label = QLabel(&quot;Input File&quot;)
          self.input_file_layout.addWidget(self.input_file_label)
          self.input_file_layout.addWidget(self.input_file)
          
  
  
  class FileInput(QWidget):
      def __init__(self, start_path=os.path.expanduser(&quot;~&quot;)) -&gt; None:
          super().__init__()
          self._main_layout = QHBoxLayout()
          self.setLayout(self._main_layout)
  
          # Add Text edit for File Input
          self._file_input = QLineEdit(start_path)
          self._main_layout.addWidget(self._file_input)
          self._file_input_browse = QPushButton(&quot;Browse&quot;)
          self._file_input_browse.clicked.connect(self._browse_file_dialog)
          self._main_layout.addWidget(self._file_input_browse)
          self._start_path = start_path
      
      def _browse_file_dialog(self):
          if os.path.isfile(self._file_input.text()):
              path = os.path.abspath(f&quot;{self._file_input.text()}/..&quot;)
          if os.path.isdir(self._file_input.text()):
              path = os.path.abspath(self._file_input.text())
          else:
              path = self._start_path
          file_name = QFileDialog.getOpenFileName(
              self, &quot;Open File&quot;, path
          )
          if len(file_name[0]) &gt; 0:
              self._file_input.setText(file_name[0])
      
      def get_path(self):
          return self._file_input.text()
  
  
  def main():
      app = QApplication(sys.argv)
      app.setStyleSheet(&quot;*{ border: 1px solid red; }&quot;)
      window = Styler_Py()
      window.show()
      app.exec()
  
  main()
  </code></pre>
  <p>I think the problem is somewhere with my custom widget but I could not find it. I have tried adding and removing a lot of the widgets but nothing happens.</p>
  <p><strong>Edit</strong>
  A Screenshot of window when resized to be a little bigger:
  <a href="https://i.stack.imgur.com/M4vyF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/M4vyF.png" alt="Screenshot but bigger window" /></a></p>