<?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[Stylesheet inheritance with pseudo-states]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">I have a stylesheet issue.<br />
Using this notation:</p>
<pre><code>#my_widget #my_label {
    color: black;
}
#my_widget:focus #my_label {
    color: white;
}
</code></pre>
<p dir="auto">my_label is always using a white text color, even if my_widget is not focused.<br />
The focus itself works, tested with background color of my_widget.</p>
<p dir="auto">Is there any reason why this descendant usage doesn't work properly?</p>
<p dir="auto">Thanks,<br />
Megamouse</p>
]]></description><link>https://forum.qt.io/topic/144814/stylesheet-inheritance-with-pseudo-states</link><generator>RSS for Node</generator><lastBuildDate>Mon, 17 Aug 2026 07:29:49 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/144814.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 02 May 2023 19:33:37 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Stylesheet inheritance with pseudo-states on Tue, 02 May 2023 21:38:35 GMT]]></title><description><![CDATA[<p dir="auto">It turns out the solution is to use the existing QProperty declarations in the QWidget header:</p>
<pre><code>#my_widget #my_label {
    color: black;
}

// This does not work
// #my_widget:focus #my_label {
//     color: white;
// }

// This works
#my_widget[focus="true"] #my_label {
    color: white;
}
</code></pre>
<p dir="auto">Sadly, to make this work, you still need to check the focus events of your parent widget and do:</p>
<pre><code>my_label-&gt;style()-&gt;unpolish(my_label);
my_label-&gt;style()-&gt;polish(my_label);
</code></pre>
<p dir="auto">Also, the hover state doesn't seem to be represented as QProperty, so I'll have to add that property manually and query the QHoverEvents</p>
]]></description><link>https://forum.qt.io/post/756842</link><guid isPermaLink="true">https://forum.qt.io/post/756842</guid><dc:creator><![CDATA[Megamouse]]></dc:creator><pubDate>Tue, 02 May 2023 21:38:35 GMT</pubDate></item></channel></rss>