PyQt application: Restore the original look & feel after changing some QSS elements
<p>I'm changing the look of some elements in my pyQt application using a QSS style sheet. This has the effect of overriding many other properties of those elements as well (as noted in the documentation and many tutorials).</p>

<p>Now, I would like to restore these overridden properties, but I haven't managed to find the "original" style sheets on my system where the default themes are defined. Using the information from these style sheets I could restore the rest of the original look.</p>

<p>Could somebody give me hint where to find these style sheets? Or is there a more elegant way to achieve my goals?</p>

<p>There are no default stylesheets. All the default styling is done by <a href="http://doc.qt.io/qt-5/style-reference.html" rel="nofollow">style plugins</a>.</p>

<p>When a stylesheet is set, it creates an instance of <code>QStyleSheetStyle</code> (which is a subclass of <code>QWindowsStyle</code>) and passes it a reference to the current style. The <code>QStyleSheetStyle</code> will try to apply the QSS rules <em>on top of</em> the current style, but where this is not possible, it will fall back to the <code>QWindowsStyle</code>.</p>

<p>And this is where the problems start, because there is no simple way to determine what a particular QSS rule will do. Sometimes it will have a very precise effect, and other times it will completely clobber the normal styling. In addition, the exact outcome depends on what the current style is. So a QSS rule might look good on your own system, but there's no guarantee it will do so on others.</p>

<p>Using stylesheets is therefore always a compromise. Creating a custom <code>QStyle</code> would give you much more control, but stylesheets will usually be much easier to write and maintain. So it's a trade-off between convenience and precision.</p>

<p>However, there is a third option available. Do nothing. Respect the user's choice of widget styling - or at the very least, don't force them to accept yours.</p>

python css user-interface pyqt qss