title: Pyqt widget lingers after being removed
body: <p>I have a QVBox layout that houses a QVBox layout and a QHBox layout. I use the other QVBox layout to hold dynamically created GUI objects and the QHBox layout to hold the buttons that add/remove those objects. Everything works correctly if I position the QHBox on top of the QVBox, but when I try to position the QHBox beneath the QVBox the objects aren't removed correctly but stay there "lingering" on top of the QHBox. I'll upload pictures to demonstrate the problem. First picture is before taking action, second is after creating a new object and third is after deleting the object</p>
  
  <p><a href="https://i.stack.imgur.com/uqqxH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/uqqxH.png" alt="Before action"></a></p>
  
  <p><a href="https://i.stack.imgur.com/NwZ9V.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NwZ9V.png" alt="After creating new component"></a></p>
  
  <p><a href="https://i.stack.imgur.com/7LCBs.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7LCBs.png" alt="After deleting the component"></a></p>
  
  <p>Here is the code that creates and deletes the new objects</p>
  
  <pre><code>    def addClient(self):
              if (len(self.clients) &lt; 5):
                      client = clientComponent(self)
                      self.clients.append(client)
                      index = len(self.clients)-1
                      self.vLayout3.addWidget(self.clients[index])
  
                      client.setIndex(index)
  
                      self.clients[index].startButton.clicked.connect(partial(self.threadcontrol, '2', client.getIndex()))
                      self.clients[index].stopButton.clicked.connect(partial(self.clientstop, '0', client.getIndex()))
  
      def deleteClient(self):
              if (len(self.clients) &gt; 1):
                      self.vLayout3.removeWidget(self.clients.pop())
  </code></pre>
  
  <p>This is where I complete the layout</p>
  
  <pre><code>    def initializeUi(self):
  
              self.mainWidget = QWidget(self)
              self.setCentralWidget(self.mainWidget)
  
              self.mainLayout = QVBoxLayout(self.mainWidget)
              self.hLayout1 = QHBoxLayout()
              self.hLayout2 = QHBoxLayout()
              self.vLayout1 = QVBoxLayout()
              self.vLayout2 = QVBoxLayout()
              self.vLayout3 = QVBoxLayout()
  
              self.addServer()
              self.addClient()
  
              self.serverBox = QGroupBox('Server')
              self.clientBox = QGroupBox('Client')
  
              self.traffic1 = QLabel('0.0Mb/s', self)
              self.traffic1.setAlignment(Qt.AlignRight)
              self.traffic2 = QLabel('0.0Mb/s', self)
              self.traffic2.setAlignment(Qt.AlignCenter)
              self.traffic3 = QLabel('0.0Mb/s', self)
              self.traffic3.setAlignment(Qt.AlignLeft)
  
              self.newClientButton = QPushButton('+', self)
              self.deleteClientButton = QPushButton('-', self)
  
              self.hLayout1.addWidget(self.traffic1)
              self.hLayout1.addWidget(self.traffic2)
              self.hLayout1.addWidget(self.traffic3)
              self.hLayout2.addWidget(self.newClientButton)
              self.hLayout2.addWidget(self.deleteClientButton)
              self.vLayout2.addLayout(self.vLayout3)
              self.vLayout2.addLayout(self.hLayout2)
  
              self.mainLayout.addWidget(self.plot)
              self.mainLayout.addLayout(self.hLayout1)
              self.serverBox.setLayout(self.vLayout1)
              self.mainLayout.addWidget(self.serverBox)
              self.clientBox.setLayout(self.vLayout2)
              self.mainLayout.addWidget(self.clientBox)
  </code></pre>