<?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 set styleSheet to all QPushButtons?]]></title><description><![CDATA[<p dir="auto">Hello.</p>
<p dir="auto">In CSS I have something like:</p>
<pre><code>h1
{
     color:red;
}
</code></pre>
<p dir="auto">which set text color in all h1 to red.</p>
<p dir="auto">I would like the same in QT ( I don't want use QML ). When I set:</p>
<pre><code>pushButton1-&gt;setStyleSheet("QPushButton {color:red;}");
</code></pre>
<p dir="auto">I set the text color only on this "pushButton1". How can I set styleSheet to all QPushButtons in my App ( using code - not uimainWindow )?</p>
]]></description><link>https://forum.qt.io/topic/118340/how-to-set-stylesheet-to-all-qpushbuttons</link><generator>RSS for Node</generator><lastBuildDate>Mon, 16 Nov 2026 00:16:50 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/118340.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 24 Aug 2020 09:21:52 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to How to set styleSheet to all QPushButtons? on Mon, 24 Aug 2020 10:15:53 GMT]]></title><description><![CDATA[<p dir="auto">@J-Hilk <a class="plugin-mentions-user plugin-mentions-a" href="/user/bonnie">@<bdi>Bonnie</bdi></a> Perfect! Thank you</p>
]]></description><link>https://forum.qt.io/post/613927</link><guid isPermaLink="true">https://forum.qt.io/post/613927</guid><dc:creator><![CDATA[TomNow99]]></dc:creator><pubDate>Mon, 24 Aug 2020 10:15:53 GMT</pubDate></item><item><title><![CDATA[Reply to How to set styleSheet to all QPushButtons? on Mon, 24 Aug 2020 10:12:47 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/tomnow99">@<bdi>TomNow99</bdi></a> sure, for example:</p>
<blockquote>
<p dir="auto">QPushButton#btnHome {  border: 1px solid rgb(87,117,131);}</p>
</blockquote>
<p dir="auto">the text after the # has to be the objectName -property of your widget</p>
]]></description><link>https://forum.qt.io/post/613926</link><guid isPermaLink="true">https://forum.qt.io/post/613926</guid><dc:creator><![CDATA[J.Hilk]]></dc:creator><pubDate>Mon, 24 Aug 2020 10:12:47 GMT</pubDate></item><item><title><![CDATA[Reply to How to set styleSheet to all QPushButtons? on Mon, 24 Aug 2020 10:08:21 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/bonnie">@<bdi>Bonnie</bdi></a> And extra question:</p>
<p dir="auto">Is there any way to add names to QWidgets?</p>
<p dir="auto">I think about this:</p>
<p dir="auto">HTML and CSS:</p>
<pre><code>&lt;div id="myDiv"&gt; &lt;/div&gt;
</code></pre>
<p dir="auto">and next</p>
<pre><code>#myDiv
{
    height: 500px;
    width: 500 px;
}
</code></pre>
<p dir="auto">So I would like use #Widget</p>
]]></description><link>https://forum.qt.io/post/613925</link><guid isPermaLink="true">https://forum.qt.io/post/613925</guid><dc:creator><![CDATA[TomNow99]]></dc:creator><pubDate>Mon, 24 Aug 2020 10:08:21 GMT</pubDate></item><item><title><![CDATA[Reply to How to set styleSheet to all QPushButtons? on Mon, 24 Aug 2020 09:25:52 GMT]]></title><description><![CDATA[<p dir="auto">You can use <code>QApplication::setStyleSheet</code>, in the <code>main.cpp</code>, like this</p>
<pre><code>QApplication app(argc, argv);
app.setStyleSheet("QPushButton {color:red;}");
</code></pre>
]]></description><link>https://forum.qt.io/post/613915</link><guid isPermaLink="true">https://forum.qt.io/post/613915</guid><dc:creator><![CDATA[Bonnie]]></dc:creator><pubDate>Mon, 24 Aug 2020 09:25:52 GMT</pubDate></item></channel></rss>