Skip to content

Commit

Permalink
corrected the deletion of layout
Browse files Browse the repository at this point in the history
  • Loading branch information
Ganar-lab committed Aug 25, 2020
1 parent 89c29c4 commit abf0cd3
Showing 1 changed file with 2 additions and 13 deletions.
15 changes: 2 additions & 13 deletions Section.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ def __init__(self, title="", animationDuration=100, parent=None):
self.toggleButton.toggled.connect(self.toggle)

def setContentLayout(self, contentLayout):
# self.clear_layout(self.contentArea.layout())
# del self.contentArea.layout()
layout = self.contentArea.layout()
del layout
self.contentArea.setLayout(contentLayout)
collapsedHeight = self.sizeHint().height() - self.contentArea.maximumHeight()
contentHeight = contentLayout.sizeHint().height()
Expand All @@ -92,17 +92,6 @@ def toggle(self, collapsed):
self.toggleAnimation.setDirection(cr.QAbstractAnimation.Backward)
self.toggleAnimation.start()


def clear_layout(self, layout):
'''Completely remove all widgets of the layout and the same for the
child layouts. Works. No memory leak. Widgets are destoryed.'''
while layout.count():
child = layout.takeAt(0)
if child.widget() is not None:
child.widget().deleteLater()
elif child.layout() is not None:
self.clear_layout(child.layout())


if __name__ == '__main__':
class Window(wd.QMainWindow):
Expand Down

0 comments on commit abf0cd3

Please sign in to comment.