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.setStyleSheet("background-color: black") outer.show() But looks like the stylesheet is not applied: entire outer window is gray. However, if w is a QWidget , code works as expected. When Canvas instance is shown directly (without parent) stylesheet is properly applied as well: w = Canvas() w.setStyleSheet("background