There is a similar question in [SO: How to make an expandable/collapsable section widget in QT](https://stackoverflow.com/q/32476006/7478597) though it is asked and answered in C++. The general concept is to have QCheckbox which shows/hide another widget (e.g. a QFrame). The rest is (hopefully) done by the Qt layout manager. To make it more stylish, you may change the look of the QCheckBox.
– Scheff's CatJul 23 '17 at 08:35