First of all, there is a different Qt StyleSheet that applies to all widgets and the html that some widgets support.
The Qt StyleSheets are a simple way to set the style and some properties to the QWidgets and that are based on CSS 2.1 but adapted to Qt.
Instead some widgets support rich text like html, and that is the case of QLabel, in this case the style must be placed inline
Considering there are several solutions:
from PySide2.QtWidgets import QApplication, QLabel, QWidget
app = QApplication([])
label = QLabel('<p style="font-size: 100px">Hello World!</p>', parent=window)
window.show()
app.exec_()
from PySide2.QtWidgets import QApplication, QLabel, QWidget
app = QApplication([])
window = QWidget()
window.setStyleSheet('''
QLabel {
font-size: 100px;
}
''')
label = QLabel('<p>Hello World!</p>', parent=window)
window.show()
app.exec_()
from PySide2.QtWidgets import QApplication, QLabel, QWidget
app = QApplication([])
window = QWidget()
label = QLabel('<p style="font-size: 100px">Hello World!</p>', parent=window)
font = label.font()
font.setPointSize(100)
label.setFont(font)
window.show()
app.exec_()
p {toQLabel {