QWidget does not draw background color

Set the WA_StyledBackground attribute on the container widget:

ui = MainWindow()
ui.setupUi(mainwindow)
ui.widget.setAttribute(QtCore.Qt.WA_StyledBackground, True)

(PS: for performance reasons, this attribute isn’t set by default for some widget classes – but the documentation doesn’t seem to specifiy which ones).

Leave a Comment