<?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[[SOLVED] QSlider handle size after stylesheet]]></title><description><![CDATA[<p dir="auto">Is it possible to get the size of the handle of a QSlider if a stylesheet changed it?</p>
<p dir="auto">The following code seems only to work if nothing changed the handles size</p>
<p dir="auto">@<br />
QStyleOptionSlider opt;<br />
initStyleOption(&amp;opt);<br />
QRect handle = style()-&gt;subControlRect(QStyle::CC_Slider, &amp;opt, QStyle::SC_SliderHandle);<br />
@</p>
]]></description><link>https://forum.qt.io/topic/36346/solved-qslider-handle-size-after-stylesheet</link><generator>RSS for Node</generator><lastBuildDate>Sun, 26 Apr 2026 03:19:55 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/36346.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 08 Jan 2014 15:11:05 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to [SOLVED] QSlider handle size after stylesheet on Thu, 09 Jan 2014 12:51:15 GMT]]></title><description><![CDATA[<p dir="auto">I should have posted the whole slider style.</p>
<p dir="auto">The <em>this</em> indeed fixed the problem. Thanks!</p>
]]></description><link>https://forum.qt.io/post/210076</link><guid isPermaLink="true">https://forum.qt.io/post/210076</guid><dc:creator><![CDATA[butterface]]></dc:creator><pubDate>Thu, 09 Jan 2014 12:51:15 GMT</pubDate></item><item><title><![CDATA[Reply to [SOLVED] QSlider handle size after stylesheet on Thu, 09 Jan 2014 12:46:21 GMT]]></title><description><![CDATA[<p dir="auto">correct, my fault.<br />
I've just tested the style definition you posted, and this isn't working as it is (only when you also style the slider's groove i think)</p>
<p dir="auto">To come back to your problem:<br />
Your code is almost correct. Just keep in mind that every time you call QStyle methods and an optional QWidget parameter is available you need to pass it:<br />
@<br />
QStyleOptionSlider opt;<br />
initStyleOption(&amp;opt);<br />
QRect handle = style()-&gt;subControlRect(QStyle::CC_Slider, &amp;opt, QStyle::SC_SliderHandle, this);<br />
@<br />
This will work.</p>
]]></description><link>https://forum.qt.io/post/210073</link><guid isPermaLink="true">https://forum.qt.io/post/210073</guid><dc:creator><![CDATA[raven-worx]]></dc:creator><pubDate>Thu, 09 Jan 2014 12:46:21 GMT</pubDate></item><item><title><![CDATA[Reply to [SOLVED] QSlider handle size after stylesheet on Thu, 09 Jan 2014 12:26:22 GMT]]></title><description><![CDATA[<p dir="auto">That is not correct. width changes the size of the handle.</p>
]]></description><link>https://forum.qt.io/post/210071</link><guid isPermaLink="true">https://forum.qt.io/post/210071</guid><dc:creator><![CDATA[butterface]]></dc:creator><pubDate>Thu, 09 Jan 2014 12:26:22 GMT</pubDate></item><item><title><![CDATA[Reply to [SOLVED] QSlider handle size after stylesheet on Thu, 09 Jan 2014 10:44:31 GMT]]></title><description><![CDATA[<p dir="auto">seems that setting the handle size via stylesheet style isn't possible at all.<br />
This is a fixed pixel metric (<em>QStyle::PM_SliderLength</em>) value in the platform styles (at least on Windows).</p>
]]></description><link>https://forum.qt.io/post/210063</link><guid isPermaLink="true">https://forum.qt.io/post/210063</guid><dc:creator><![CDATA[raven-worx]]></dc:creator><pubDate>Thu, 09 Jan 2014 10:44:31 GMT</pubDate></item><item><title><![CDATA[Reply to [SOLVED] QSlider handle size after stylesheet on Thu, 09 Jan 2014 10:20:25 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sgaist">@<bdi>SGaist</bdi></a> Of course this would be an option but I would prefer to ask the slider itself for its handle size.</p>
]]></description><link>https://forum.qt.io/post/210059</link><guid isPermaLink="true">https://forum.qt.io/post/210059</guid><dc:creator><![CDATA[butterface]]></dc:creator><pubDate>Thu, 09 Jan 2014 10:20:25 GMT</pubDate></item><item><title><![CDATA[Reply to [SOLVED] QSlider handle size after stylesheet on Thu, 09 Jan 2014 10:19:08 GMT]]></title><description><![CDATA[<p dir="auto">I don't know why.</p>
<p dir="auto">The output gives me a width of the handle of 15 but it should be 18.</p>
<p dir="auto">@<br />
QSlider::handle:horizontal {<br />
background: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 #b4b4b4, stop:1 #8f8f8f);<br />
border: 1px solid #0c457e;<br />
width: 18px;<br />
margin: -2px 0;<br />
border-radius: 3px;<br />
}<br />
@</p>
]]></description><link>https://forum.qt.io/post/210058</link><guid isPermaLink="true">https://forum.qt.io/post/210058</guid><dc:creator><![CDATA[butterface]]></dc:creator><pubDate>Thu, 09 Jan 2014 10:19:08 GMT</pubDate></item><item><title><![CDATA[Reply to [SOLVED] QSlider handle size after stylesheet on Thu, 09 Jan 2014 07:16:38 GMT]]></title><description><![CDATA[<p dir="auto">[quote author="butterface" date="1389193865"]<br />
The following code seems only to work if nothing changed the handles size<br />
[/quote]<br />
why doesn't this code work for you?<br />
How does the output differ from what you expect?<br />
How does your stylesheet look like?</p>
]]></description><link>https://forum.qt.io/post/210023</link><guid isPermaLink="true">https://forum.qt.io/post/210023</guid><dc:creator><![CDATA[raven-worx]]></dc:creator><pubDate>Thu, 09 Jan 2014 07:16:38 GMT</pubDate></item><item><title><![CDATA[Reply to [SOLVED] QSlider handle size after stylesheet on Wed, 08 Jan 2014 20:40:59 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">You could parse the stylesheet for that information</p>
]]></description><link>https://forum.qt.io/post/209961</link><guid isPermaLink="true">https://forum.qt.io/post/209961</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Wed, 08 Jan 2014 20:40:59 GMT</pubDate></item></channel></rss>