Issue
I have an QHBoxLayout
with a QTreeWidget
on the left, a separator on the middle and a widget on the right.
When I click on the QTreeWidget
, I want to change the widget on the right to modify the QTreeWidgetItem
I tried to do this with this 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)
But it doesn't work and all the widgets are stacked up on each other :
(source: free.fr)
.
Do you know how I can remove the old widget and next display the new one ?
Solution
The most common solution is to use QStackedWidget
and put all possible widgets into the stack. When selecting an item, just call setCurrentWidget
to display the one you want.
Answered By - Lukáลก Lalinský
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.