<?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 on widgets containing a given string?]]></title><description><![CDATA[<p dir="auto">Is it possible on qt designer to apply the stylesheet only on widgets containing a given string?<br />
Something like</p>
<pre><code>[objectName*="test_"] 
{
    background-color: red;
}
</code></pre>
<p dir="auto">It would set the bg red on any widget containing <code>test_</code> on its object name.</p>
]]></description><link>https://forum.qt.io/topic/146115/how-to-set-stylesheet-on-widgets-containing-a-given-string</link><generator>RSS for Node</generator><lastBuildDate>Sat, 24 Oct 2026 22:48:27 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/146115.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 30 Jun 2023 17:35:30 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to How to set stylesheet on widgets containing a given string? on Sat, 01 Jul 2023 07:07:36 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/daniella">@<bdi>Daniella</bdi></a><br />
Things can go wrong on parenting the widgets into each other. The child may inherit its parent’s stylesheet. In that case the parent probably has the same background color. So the only noticeable difference is padding.</p>
<p dir="auto">It also matters if <code>test</code> becomes true before or after the setting the stylesheet. If it happens afterwards, you have to enforce manual recomputing.</p>
<p dir="auto">Whatever it is, setting the child’s stylesheet (again), should solve both issues.</p>
]]></description><link>https://forum.qt.io/post/763243</link><guid isPermaLink="true">https://forum.qt.io/post/763243</guid><dc:creator><![CDATA[Axel Spoerl]]></dc:creator><pubDate>Sat, 01 Jul 2023 07:07:36 GMT</pubDate></item><item><title><![CDATA[Reply to How to set stylesheet on widgets containing a given string? on Fri, 30 Jun 2023 17:51:09 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jonb">@<bdi>JonB</bdi></a> said in <a href="/post/763217">How to set stylesheet on widgets containing a given string?</a>:</p>
<blockquote>
<p dir="auto">Your only chance would be by using <a href="https://doc.qt.io/qt-6/stylesheet-examples.html#customizing-using-dynamic-properties" target="_blank" rel="noopener noreferrer nofollow ugc">dynamic properties</a>, but I don't think that will allow <strong>objectName</strong> as a <em>partial</em> match, no "containing" a substring.  The only mention of "syntax" is <a href="https://doc.qt.io/qt-6/stylesheet-syntax.html#selector-types" target="_blank" rel="noopener noreferrer nofollow ugc">https://doc.qt.io/qt-6/stylesheet-syntax.html#selector-types</a></p>
<blockquote>
<p dir="auto">Instead of =, you can also use ~= to test whether a Qt property of type QStringList contains a given QString.</p>
</blockquote>
</blockquote>
<p dir="auto">When i have a QWidget inside another QWidget the padding doesnt work, im doing something wrong?</p>
<pre><code>QWidget[test="true"]
{
	background-color: #3c3f45;
	padding-left: 32px;
}
</code></pre>
]]></description><link>https://forum.qt.io/post/763220</link><guid isPermaLink="true">https://forum.qt.io/post/763220</guid><dc:creator><![CDATA[Daniella]]></dc:creator><pubDate>Fri, 30 Jun 2023 17:51:09 GMT</pubDate></item><item><title><![CDATA[Reply to How to set stylesheet on widgets containing a given string? on Fri, 30 Jun 2023 17:46:10 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/daniella">@<bdi>Daniella</bdi></a><br />
Your only chance would be by using <a href="https://doc.qt.io/qt-6/stylesheet-examples.html#customizing-using-dynamic-properties" target="_blank" rel="noopener noreferrer nofollow ugc">dynamic properties</a>, but I don't think that will allow <strong>objectName</strong> as a <em>partial</em> match, no "containing" a substring.  The only mention of "syntax" is <a href="https://doc.qt.io/qt-6/stylesheet-syntax.html#selector-types" target="_blank" rel="noopener noreferrer nofollow ugc">https://doc.qt.io/qt-6/stylesheet-syntax.html#selector-types</a></p>
<blockquote>
<p dir="auto">Instead of =, you can also use ~= to test whether a Qt property of type QStringList contains a given QString.</p>
</blockquote>
]]></description><link>https://forum.qt.io/post/763217</link><guid isPermaLink="true">https://forum.qt.io/post/763217</guid><dc:creator><![CDATA[JonB]]></dc:creator><pubDate>Fri, 30 Jun 2023 17:46:10 GMT</pubDate></item></channel></rss>