Skip to content Skip to sidebar Skip to footer

Stylesheet For Nested Custom Widget Not Applied

I expect the following code to show a small black area inside outer main window: class Canvas(QWidget): pass app = QApplication(sys.argv) outer = QWidget() w = Canvas(outer) w

Solution 1:

A QWidget subclass will ignore stylesheets by default (for performance reasons).

Try this:

w = Canvas(outer)
w.setAttribute(QtCore.Qt.WA_StyledBackground)
w.setStyleSheet("background-color: black")

Post a Comment for "Stylesheet For Nested Custom Widget Not Applied"