To summarise for anyone reading this. Thanks to the answers above. You can assign a dynamic property, with a name and value of your choice, via QWidget.setProperty("cssClass", "large"). The stylesheet can match this via selector *[cssClass="large"] { ... }. You can assign multiple values to the property via QWidget.setProperty("cssClass", [ "bold", "large", "rounded" ]). (Or it accepts a space-separated string via "bold large rounded".) The stylesheet can match one of the values via selector *[cssClass~="large"] { ... } (note the ~=). Note that property named class is a special one, referring to the Python/C++ code class of the widget, which you probably should not assign to.