QScrollArea with dynamically changing contents

The essential steps are: The container widget that holds the buttons (your CheckableButtonGroup) must have a QLayout::SetMinAndMaxSize size constraint set. Then it will be exactly large enough to hold the buttons. Its size policy doesn’t matter, since you’re simply putting it into a QScrollArea, not into another layout. The scroll area needs to set its … Read more

Set background color of layout

You could just add set the layout on an empty QWidget and set the StyleSheet on this widget. for index, param_name in enumerate(parameters): container = QtGui.QWidget(self) layout = QtGui.QHBoxLayout(container ) hlayouts.append(container) labels.append(QtGui.QLabel(“%s”%param_name)) sliders.append(QtGui.QSpacerItem(10,10,hPolicy=QtGui.QSizePolicy.Expanding)) spins.append(QtGui.QDoubleSpinBox()) spins[index].setValue(float(values.get(param_name))) container.setStyleSheet(“background-color:black;”) layout.addWidget(labels[index]) layout.addItem(sliders[index]) layout.addWidget(spins[index]) vlayout = QtGui.QVBoxLayout(self) for widget in hlayouts: vlayout.addWidget(widget)