<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[How to exclude a specific widget from the global stylesheet?]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">In my application I set a global stylesheet, for example:</p>
<p dir="auto">qApp-&gt;setStyleSheet("QPushButton { background-color: red; }");</p>
<p dir="auto">This works fine, but now I want one specific QPushButton not to use the global style and instead use the default system look.</p>
<p dir="auto">I tried setting a different stylesheet on that button, but it still inherits the global rules.</p>
<p dir="auto">Question:<br />
How can I clear or override the global stylesheet for a single widget, so that it is rendered with the default system style instead of the global QSS?</p>
<p dir="auto">Thanks!</p>
]]></description><link>https://forum.qt.io/topic/163380/how-to-exclude-a-specific-widget-from-the-global-stylesheet</link><generator>RSS for Node</generator><lastBuildDate>Thu, 05 Nov 2026 01:54:01 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/163380.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 30 Sep 2025 02:25:26 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to How to exclude a specific widget from the global stylesheet? on Wed, 01 Oct 2025 06:56:30 GMT]]></title><description><![CDATA[<p dir="auto">You can see if any of the selectors (<a href="https://doc.qt.io/qt-6/stylesheet-syntax.html" target="_blank" rel="noopener noreferrer nofollow ugc">https://doc.qt.io/qt-6/stylesheet-syntax.html</a>) work for you. You could create your own subclass of <code>QPushButton</code>. As long as all the other buttons are actual <code>QPushButton</code>s the class selector <code>.QPushButton</code> would only style these, but not your subclass. Or you could try to use a Property Selector with your own property. But I'm not sure if that works for buttons that <strong>don't</strong> have that property. (You see, it is a lot easier to just specify something for a specific button, but a lot harder to specify something for all other buttons.)</p>
]]></description><link>https://forum.qt.io/post/832278</link><guid isPermaLink="true">https://forum.qt.io/post/832278</guid><dc:creator><![CDATA[SimonSchroeder]]></dc:creator><pubDate>Wed, 01 Oct 2025 06:56:30 GMT</pubDate></item><item><title><![CDATA[Reply to How to exclude a specific widget from the global stylesheet? on Tue, 30 Sep 2025 08:18:56 GMT]]></title><description><![CDATA[<p dir="auto">You can't "un-inherit" stylesheet. You can only overrride it with other value of the same property.</p>
]]></description><link>https://forum.qt.io/post/832208</link><guid isPermaLink="true">https://forum.qt.io/post/832208</guid><dc:creator><![CDATA[Bonnie]]></dc:creator><pubDate>Tue, 30 Sep 2025 08:18:56 GMT</pubDate></item><item><title><![CDATA[Reply to How to exclude a specific widget from the global stylesheet? on Tue, 30 Sep 2025 07:07:24 GMT]]></title><description><![CDATA[<pre><code>TEMPLATE = app
TARGET = test
INCLUDEPATH += .
QT+= widgets
SOURCES += main.cpp
</code></pre>
<pre><code>#include &lt;QApplication&gt;
#include &lt;QWidget&gt;
#include &lt;QPushButton&gt;
#include &lt;QVBoxLayout&gt;

class BoringButton: public QPushButton {
        Q_OBJECT
public:
        explicit BoringButton(const QString &amp;text, QWidget *parent = nullptr): QPushButton(text, parent) { }
};

int main(int argc, char **argv) {
        QApplication app(argc, argv);

        QWidget widget;
        QString originalStyleSheet = widget.styleSheet();
        widget.setStyleSheet( ".QPushButton { background-color: cyan; } ");
        
        QVBoxLayout *layout = new QVBoxLayout(&amp;widget);
        QPushButton *button1 = new QPushButton("Styled");
        layout-&gt;addWidget(button1);

        QPushButton *button2 = new BoringButton("Default");
        layout-&gt;addWidget(button2);

        widget.show();
        return app.exec();
}

#include "main.moc"
</code></pre>
<p dir="auto"><img src="https://ddgobkiprc33d.cloudfront.net/77bc1772-77b9-4a79-bdeb-105425a67d3f.png" alt="99a1ccb3-be73-4e77-bafa-f2d1dd63178d-image.png" class=" img-fluid img-markdown" /></p>
]]></description><link>https://forum.qt.io/post/832206</link><guid isPermaLink="true">https://forum.qt.io/post/832206</guid><dc:creator><![CDATA[ChrisW67]]></dc:creator><pubDate>Tue, 30 Sep 2025 07:07:24 GMT</pubDate></item><item><title><![CDATA[Reply to How to exclude a specific widget from the global stylesheet? on Tue, 30 Sep 2025 05:05:24 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/qt123">@<bdi>Qt123</bdi></a> said in <a href="/post/832195">How to exclude a specific widget from the global stylesheet?</a>:</p>
<blockquote>
<p dir="auto">I tried setting a different stylesheet on that button, but it still inherits the global rules.</p>
</blockquote>
<p dir="auto">That should work. How do you do it?</p>
]]></description><link>https://forum.qt.io/post/832200</link><guid isPermaLink="true">https://forum.qt.io/post/832200</guid><dc:creator><![CDATA[jsulm]]></dc:creator><pubDate>Tue, 30 Sep 2025 05:05:24 GMT</pubDate></item></channel></rss>