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)

Qt Stylesheet for custom widget

I had a similar problem and it was solved using jecjackal’s comment. As sjwarner said, it would be much more noticeable in the form of an answer. So I’ll provide it. For the benefit of any future viewers. Again, it isn’t my answer! Appreciate jecjackal for it! As it is said in the Qt’s stylesheets … Read more