title: How to replace a Widget with another using Qt?
body: <p>I have an <code>QHBoxLayout</code> with a <code>QTreeWidget</code> on the left, a separator on the middle and a widget on the right.</p>
  <p>When I click on the <code>QTreeWidget</code>, I want to change the widget on the right to modify the <code>QTreeWidgetItem</code></p>
  <p>I tried to do this with this code :</p>
  <pre><code>def new_rendez_vous(self):
      self.ui.horizontalLayout_4.removeWidget(self.ui.editionFormWidget)
      del self.ui.editionFormWidget
      self.ui.editionFormWidget = RendezVousManagerDialog(self.parent)
      self.ui.editionFormWidget.show()
      self.ui.horizontalLayout_4.addWidget(self.ui.editionFormWidget)
      self.connect(self.ui.editionFormWidget, QtCore.SIGNAL('saved'), self.scheduleTreeWidget.updateData)
  
  def edit(self, category, rendez_vous):
      self.ui.horizontalLayout_4.removeWidget(self.ui.editionFormWidget)
      del self.ui.editionFormWidget
      self.ui.editionFormWidget = RendezVousManagerDialog(self.parent, category, rendez_vous)
      self.ui.editionFormWidget.show()
      self.ui.horizontalLayout_4.addWidget(self.ui.editionFormWidget)
      self.connect(self.ui.editionFormWidget, QtCore.SIGNAL('saved'), self.scheduleTreeWidget.updateData)
  
  def edit_category(self, category):
      self.ui.horizontalLayout_4.removeWidget(self.ui.editionFormWidget)
      del self.ui.editionFormWidget
      self.ui.editionFormWidget = CategoryManagerDialog(self.parent, category)
      self.ui.editionFormWidget.show()
      self.ui.horizontalLayout_4.addWidget(self.ui.editionFormWidget)
      self.connect(self.ui.editionFormWidget, QtCore.SIGNAL('saved'), self.scheduleTreeWidget.updateData)
  </code></pre>
  <p>But it doesn't work and all the widgets are stacked up on each other :</p>
  <p><a href="https://i.stack.imgur.com/Ulx2a.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Ulx2a.jpg" alt="Exemple of the bug" /></a><br />
  <sub>(source: <a href="http://hubscher.remy.free.fr/tally/images/2011/01/07/CaptureDescribingTheBug525.jpg" rel="nofollow noreferrer">free.fr</a>)</sub><br />
  .</p>
  <p>Do you know how I can remove the old widget and next display the new one ?</p>