def _setLayout(self, contentLayout: QLayout): self._contentArea.setLayout(contentLayout) collapsedHeight = self.sizeHint().height( ) - self._contentArea.maximumHeight() contentHeight = contentLayout.sizeHint().height() for i in range(self._toggleAnimation.animationCount() - 1): SectionAnimation = self._toggleAnimation.animationAt(i) SectionAnimation.setDuration(self._animationDuration) SectionAnimation.setStartValue(collapsedHeight) SectionAnimation.setEndValue(collapsedHeight + contentHeight) contentAnimation = self._toggleAnimation.animationAt( self._toggleAnimation.animationCount() - 1) contentAnimation.setDuration(self._animationDuration) contentAnimation.setStartValue(0) contentAnimation.setEndValue(contentHeight)