class customWidget(QWidget): def init(self, parent=None): super(customWidget, self).init(parent)
class Window1(QWidget): def init(self): super(Window1, self).init() self.setFixedSize(800, 600) self.initUI()
def initUI(self):
vbox = QVBoxLayout()
a = customWidget(self)
a.setStyleSheet("background-color: red;")
vbox.addWidget(a)
self.setLayout(vbox)
enter image description here class Window2(QWidget): def init(self): super(Window2, self).init() self.setFixedSize(800, 600) self.initUI()
def initUI(self):
vbox = QVBoxLayout()
a = QWidget(self)
a.setStyleSheet("background-color: red;")
vbox.addWidget(a)
self.setLayout(vbox)
what's the difference between fig1 and fig2, how can i make the same effect in window with window2