First: add a valid widget to your example:
self.widget = QWidget(self)
layout = QVBoxLayout(self)
layout.addWidget(self.widget)
Second: do yourself a favor and use triple quotes:
self.widget.setStyleSheet("""
.QWidget {
border: 20px solid black;
border-radius: 10px;
background-color: rgb(255, 255, 255);
}
""")
NB: the point selector in your example is redundant. What he does is indicate that only instances will be selected QWidget, not subclasses QWidget. See the StyleSheet syntax guide in Qt docs.
source
share