Set background color of layout

六眼飞鱼酱① 提交于 2019-12-01 18:20:11

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)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!