<?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[Subclassing QSlider with handle as a Widget]]></title><description><![CDATA[<p dir="auto">Hello,</p>
<p dir="auto">I want to draw a custom widget in the slider handle, I have no idea how to do that?<br />
Do you think I could achieve this by subclassing QSlider or QAbstractSlider?</p>
<p dir="auto">Cheers,</p>
]]></description><link>https://forum.qt.io/topic/37332/subclassing-qslider-with-handle-as-a-widget</link><generator>RSS for Node</generator><lastBuildDate>Sat, 25 Apr 2026 01:00:48 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/37332.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 03 Feb 2014 21:45:02 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Subclassing QSlider with handle as a Widget on Wed, 05 Feb 2014 08:17:57 GMT]]></title><description><![CDATA[<p dir="auto">Its probably me who misunderstood :D<br />
I  wanted a separated widget for architecture reasons, to make it modular.<br />
Lets say that tomorrow I decide that it will not be a slider but something else.<br />
Or I want to render this customwidget in another view in my software ...</p>
<p dir="auto">There are a lot of reasons :)</p>
]]></description><link>https://forum.qt.io/post/213546</link><guid isPermaLink="true">https://forum.qt.io/post/213546</guid><dc:creator><![CDATA[BlackMamba]]></dc:creator><pubDate>Wed, 05 Feb 2014 08:17:57 GMT</pubDate></item><item><title><![CDATA[Reply to Subclassing QSlider with handle as a Widget on Wed, 05 Feb 2014 08:02:38 GMT]]></title><description><![CDATA[<p dir="auto">I think you misunderstood me ( or maybe I misunderstand you :-) )<br />
Why do you need a "customwidget" at all ? Consider that your "customwidget" is slider handle. You can render this "handle" in the way you want, also you can intercept mouse events for slider and filter these for "handle" rect.</p>
]]></description><link>https://forum.qt.io/post/213539</link><guid isPermaLink="true">https://forum.qt.io/post/213539</guid><dc:creator><![CDATA[cincirin]]></dc:creator><pubDate>Wed, 05 Feb 2014 08:02:38 GMT</pubDate></item><item><title><![CDATA[Reply to Subclassing QSlider with handle as a Widget on Tue, 04 Feb 2014 21:14:08 GMT]]></title><description><![CDATA[<p dir="auto">Hello again,</p>
<p dir="auto">I didn't know we could render a widget with QPainter, I never did like that in the past.<br />
You are talking about :</p>
<p dir="auto">painter-&gt;begin(mycustomwidget);   right?</p>
<p dir="auto">Looks like there is also itemChange if I forget about the idea of subclassing a QSlider ....</p>
]]></description><link>https://forum.qt.io/post/213486</link><guid isPermaLink="true">https://forum.qt.io/post/213486</guid><dc:creator><![CDATA[BlackMamba]]></dc:creator><pubDate>Tue, 04 Feb 2014 21:14:08 GMT</pubDate></item><item><title><![CDATA[Reply to Subclassing QSlider with handle as a Widget on Tue, 04 Feb 2014 19:27:53 GMT]]></title><description><![CDATA[<p dir="auto">What's wrong by subclassing QSlider and reimplement all mouse events you need ? Also you can paint the slider handle either in paint event or using stylesheet. So you have a complete control on slider handle.</p>
]]></description><link>https://forum.qt.io/post/213475</link><guid isPermaLink="true">https://forum.qt.io/post/213475</guid><dc:creator><![CDATA[cincirin]]></dc:creator><pubDate>Tue, 04 Feb 2014 19:27:53 GMT</pubDate></item><item><title><![CDATA[Reply to Subclassing QSlider with handle as a Widget on Tue, 04 Feb 2014 14:14:59 GMT]]></title><description><![CDATA[<p dir="auto">Yes it was as I thought. So how do I do ? :D</p>
]]></description><link>https://forum.qt.io/post/213438</link><guid isPermaLink="true">https://forum.qt.io/post/213438</guid><dc:creator><![CDATA[BlackMamba]]></dc:creator><pubDate>Tue, 04 Feb 2014 14:14:59 GMT</pubDate></item><item><title><![CDATA[Reply to Subclassing QSlider with handle as a Widget on Tue, 04 Feb 2014 14:13:00 GMT]]></title><description><![CDATA[<p dir="auto">I'm not using stylesheet in example posted. The default slider handle is rendering by application style and the other two are QLabels with image pixmap.</p>
]]></description><link>https://forum.qt.io/post/213435</link><guid isPermaLink="true">https://forum.qt.io/post/213435</guid><dc:creator><![CDATA[cincirin]]></dc:creator><pubDate>Tue, 04 Feb 2014 14:13:00 GMT</pubDate></item><item><title><![CDATA[Reply to Subclassing QSlider with handle as a Widget on Tue, 04 Feb 2014 13:40:53 GMT]]></title><description><![CDATA[<p dir="auto">And how to you render the customWidget with stylesheet?</p>
]]></description><link>https://forum.qt.io/post/213432</link><guid isPermaLink="true">https://forum.qt.io/post/213432</guid><dc:creator><![CDATA[BlackMamba]]></dc:creator><pubDate>Tue, 04 Feb 2014 13:40:53 GMT</pubDate></item><item><title><![CDATA[Reply to Subclassing QSlider with handle as a Widget on Tue, 04 Feb 2014 13:27:26 GMT]]></title><description><![CDATA[<p dir="auto">In my example with yes, but I needed three handles not one. With only one handle you can use QSlider signals, events and style(sheets) without any other additional widget(s)</p>
]]></description><link>https://forum.qt.io/post/213429</link><guid isPermaLink="true">https://forum.qt.io/post/213429</guid><dc:creator><![CDATA[cincirin]]></dc:creator><pubDate>Tue, 04 Feb 2014 13:27:26 GMT</pubDate></item><item><title><![CDATA[Reply to Subclassing QSlider with handle as a Widget on Tue, 04 Feb 2014 13:24:04 GMT]]></title><description><![CDATA[<p dir="auto">ok :)</p>
<p dir="auto">And for painting the customwidget, you just instantiate it into the paint method of the subclasses slider and parent it to the subclassed slider?</p>
]]></description><link>https://forum.qt.io/post/213427</link><guid isPermaLink="true">https://forum.qt.io/post/213427</guid><dc:creator><![CDATA[BlackMamba]]></dc:creator><pubDate>Tue, 04 Feb 2014 13:24:04 GMT</pubDate></item><item><title><![CDATA[Reply to Subclassing QSlider with handle as a Widget on Tue, 04 Feb 2014 13:20:02 GMT]]></title><description><![CDATA[<p dir="auto">Yes you can reimplement all of these events in QSlider subclass, and filter all mouse events for handle rect only. Thats all ...<br />
@<br />
if (style()-&gt;subControlRect(etc).contains(event-&gt;pos())<br />
@</p>
]]></description><link>https://forum.qt.io/post/213428</link><guid isPermaLink="true">https://forum.qt.io/post/213428</guid><dc:creator><![CDATA[cincirin]]></dc:creator><pubDate>Tue, 04 Feb 2014 13:20:02 GMT</pubDate></item><item><title><![CDATA[Reply to Subclassing QSlider with handle as a Widget on Tue, 04 Feb 2014 13:15:58 GMT]]></title><description><![CDATA[<p dir="auto">I need these ones on the handle:<br />
virtual void mouseDoubleClickEvent(QMouseEvent * event)<br />
virtual void mouseMoveEvent(QMouseEvent * event)<br />
virtual void mousePressEvent(QMouseEvent * event)<br />
virtual void mouseReleaseEvent(QMouseEvent * event)<br />
virtual void moveEvent(QMoveEvent * event)</p>
<p dir="auto">If I understand you, you want to "render" the CustomWidget without embedding it to the handle and filter the events on the rectangle zone and not on the customwidget?</p>
]]></description><link>https://forum.qt.io/post/213425</link><guid isPermaLink="true">https://forum.qt.io/post/213425</guid><dc:creator><![CDATA[BlackMamba]]></dc:creator><pubDate>Tue, 04 Feb 2014 13:15:58 GMT</pubDate></item><item><title><![CDATA[Reply to Subclassing QSlider with handle as a Widget on Tue, 04 Feb 2014 13:05:13 GMT]]></title><description><![CDATA[<p dir="auto">bq. I need them on the slider’s handle</p>
<p dir="auto">Which one exactly ?<br />
Basically you can subclass slider, obtain a rect of the handle style()-&gt;subControlRect and from here you can filter all mouse events from handle only. For paint of course you can reimplement paintEvent, but with style sheet is easily. What other events do you need ?</p>
]]></description><link>https://forum.qt.io/post/213422</link><guid isPermaLink="true">https://forum.qt.io/post/213422</guid><dc:creator><![CDATA[cincirin]]></dc:creator><pubDate>Tue, 04 Feb 2014 13:05:13 GMT</pubDate></item><item><title><![CDATA[Reply to Subclassing QSlider with handle as a Widget on Tue, 04 Feb 2014 12:54:21 GMT]]></title><description><![CDATA[<p dir="auto">These events are enough yes, but I need them on the slider's handle, not on the slider itself ;)</p>
]]></description><link>https://forum.qt.io/post/213419</link><guid isPermaLink="true">https://forum.qt.io/post/213419</guid><dc:creator><![CDATA[BlackMamba]]></dc:creator><pubDate>Tue, 04 Feb 2014 12:54:21 GMT</pubDate></item><item><title><![CDATA[Reply to Subclassing QSlider with handle as a Widget on Tue, 04 Feb 2014 12:46:39 GMT]]></title><description><![CDATA[<p dir="auto">Ok, what events do you need ?<br />
Isn't the default "signals":<a href="http://qt-project.org/doc/qt-5/qabstractslider.html#signals" target="_blank" rel="noopener noreferrer nofollow ugc">http://qt-project.org/doc/qt-5/qabstractslider.html#signals</a> what you need ?</p>
]]></description><link>https://forum.qt.io/post/213418</link><guid isPermaLink="true">https://forum.qt.io/post/213418</guid><dc:creator><![CDATA[cincirin]]></dc:creator><pubDate>Tue, 04 Feb 2014 12:46:39 GMT</pubDate></item><item><title><![CDATA[Reply to Subclassing QSlider with handle as a Widget on Tue, 04 Feb 2014 12:41:00 GMT]]></title><description><![CDATA[<p dir="auto">[quote author="cincirin" date="1391517392"]"Customizing QSlider":<a href="http://qt-project.org/doc/qt-4.8/stylesheet-examples.html#customizing-qslider" target="_blank" rel="noopener noreferrer nofollow ugc">http://qt-project.org/doc/qt-4.8/stylesheet-examples.html#customizing-qslider</a></p>
<p dir="auto">See how to customize the slider groove and slider handle[/quote]</p>
<p dir="auto">:)</p>
<p dir="auto">Cincirin, I know about this already :)<br />
But this is just to customize the appearance of the handle, not transforming it to a custom widget on which you can add events, etc ...<br />
Or am I mistaken?</p>
]]></description><link>https://forum.qt.io/post/213415</link><guid isPermaLink="true">https://forum.qt.io/post/213415</guid><dc:creator><![CDATA[BlackMamba]]></dc:creator><pubDate>Tue, 04 Feb 2014 12:41:00 GMT</pubDate></item><item><title><![CDATA[Reply to Subclassing QSlider with handle as a Widget on Tue, 04 Feb 2014 12:36:32 GMT]]></title><description><![CDATA[<p dir="auto">"Customizing QSlider":<a href="http://qt-project.org/doc/qt-4.8/stylesheet-examples.html#customizing-qslider" target="_blank" rel="noopener noreferrer nofollow ugc">http://qt-project.org/doc/qt-4.8/stylesheet-examples.html#customizing-qslider</a></p>
<p dir="auto">See how to customize the slider groove and slider handle</p>
]]></description><link>https://forum.qt.io/post/213414</link><guid isPermaLink="true">https://forum.qt.io/post/213414</guid><dc:creator><![CDATA[cincirin]]></dc:creator><pubDate>Tue, 04 Feb 2014 12:36:32 GMT</pubDate></item><item><title><![CDATA[Reply to Subclassing QSlider with handle as a Widget on Tue, 04 Feb 2014 12:28:24 GMT]]></title><description><![CDATA[<p dir="auto">Cincirin,</p>
<p dir="auto">Yes I need to move a widget from left to right within a certain range.<br />
I had the idea of a slider because it looks convenient for what I want to achieve ;) (left to right implemented, start and end positions, etc ...)<br />
I am sorry if I explained it in the wrong way.</p>
<p dir="auto">[quote author="cincirin" date="1391516376"]If yes, you can use slider directly and either use style sheets or implement a custom style to draw/paint slider “widget” value.[/quote]</p>
<p dir="auto">Here is my issue, I don't know how to paint the widget on the slider's handle. I don't think stylesheet can achieve that does it?<br />
And for custom style, how to access the handle.</p>
<p dir="auto">The normal way to go if the slider's handle was a class would be to subclass it and reimplement the paint method.<br />
I am not familiar with QStyle at all, it's probably the reason why I don't know how to do this ....</p>
]]></description><link>https://forum.qt.io/post/213412</link><guid isPermaLink="true">https://forum.qt.io/post/213412</guid><dc:creator><![CDATA[BlackMamba]]></dc:creator><pubDate>Tue, 04 Feb 2014 12:28:24 GMT</pubDate></item><item><title><![CDATA[Reply to Subclassing QSlider with handle as a Widget on Tue, 04 Feb 2014 12:19:36 GMT]]></title><description><![CDATA[<p dir="auto">I'm sorry but I don't understand exactly what is your requirement.<br />
In my example I really needed a slider with three values and signals when one of the three value is changed.<br />
From what I understand you only need a "widget" which is moved horizontally from left to right. Is this correct ? If yes, you can use slider directly and either use style sheets or implement a custom style to draw/paint slider "widget" value.</p>
]]></description><link>https://forum.qt.io/post/213410</link><guid isPermaLink="true">https://forum.qt.io/post/213410</guid><dc:creator><![CDATA[cincirin]]></dc:creator><pubDate>Tue, 04 Feb 2014 12:19:36 GMT</pubDate></item><item><title><![CDATA[Reply to Subclassing QSlider with handle as a Widget on Tue, 04 Feb 2014 11:50:40 GMT]]></title><description><![CDATA[<p dir="auto">Hello,</p>
<p dir="auto">I really appreciate your help.<br />
I want to draw an audio sinus wave in a SinusWidget to be positonned on a time line widget.<br />
This SinusWidget will be able to move horizontally from left to right depending on when you want the sinus wave to be played.<br />
I should also have events connected to the SinusWidget to be able to change its width.</p>
<p dir="auto">Because of this, I was thinking about a slider to provide embedded SinusWidget via the handle.</p>
<p dir="auto">Something like this.</p>
<p dir="auto">initial example :<br />
ISINUS WIDGETI-----------------------------------------</p>
<p dir="auto">position changed:<br />
-----------------------------ISINUS WIDGETI------------</p>
<p dir="auto">width changed:<br />
----------------ISINUS ________ WIDGETI-----------------</p>
<p dir="auto">What do you think about it?</p>
]]></description><link>https://forum.qt.io/post/213407</link><guid isPermaLink="true">https://forum.qt.io/post/213407</guid><dc:creator><![CDATA[BlackMamba]]></dc:creator><pubDate>Tue, 04 Feb 2014 11:50:40 GMT</pubDate></item><item><title><![CDATA[Reply to Subclassing QSlider with handle as a Widget on Tue, 04 Feb 2014 11:24:30 GMT]]></title><description><![CDATA[<p dir="auto">bq. could you please tell me with 2 lines of codes how you acheieved that?</p>
<p dir="auto">Of course I can, but as Andre said is better to tell us what are you trying to achieve and what are your attempts to implement them ?</p>
<p dir="auto">bq. Can you move these two QLabels?</p>
<p dir="auto">Yes any widget can be moved, just set the widget position depending on your requirements.</p>
<p dir="auto">So in short here is my implementation:</p>
<ul>
<li>
<ul>
<li>subclass QSlider and create two labels in constructor having parent this slider</li>
</ul>
</li>
<li>
<ul>
<li>in slider resizeEvent, move the two labels in respect with new slider width</li>
</ul>
</li>
<li>
<ul>
<li>for the two labels install event filter ON slider object ( or you can subclass labels to implement mouse press/move/release )</li>
</ul>
</li>
<li>
<ul>
<li>in slider event filter I check for mouse press/move/release for the two labels and move them accordingly</li>
</ul>
</li>
</ul>
]]></description><link>https://forum.qt.io/post/213404</link><guid isPermaLink="true">https://forum.qt.io/post/213404</guid><dc:creator><![CDATA[cincirin]]></dc:creator><pubDate>Tue, 04 Feb 2014 11:24:30 GMT</pubDate></item><item><title><![CDATA[Reply to Subclassing QSlider with handle as a Widget on Tue, 04 Feb 2014 10:56:17 GMT]]></title><description><![CDATA[<p dir="auto">Could you tell us what you want to achieve? What would you like to put on the handle? If it is just a label, it might be easier to render that content yourself in your QSlider subclass.</p>
]]></description><link>https://forum.qt.io/post/213401</link><guid isPermaLink="true">https://forum.qt.io/post/213401</guid><dc:creator><![CDATA[andre]]></dc:creator><pubDate>Tue, 04 Feb 2014 10:56:17 GMT</pubDate></item><item><title><![CDATA[Reply to Subclassing QSlider with handle as a Widget on Tue, 04 Feb 2014 09:43:18 GMT]]></title><description><![CDATA[<p dir="auto">Thank you very much for your answers.<br />
I want to have the behaviour of a slider I just want the handle to be a rectangle widget to draw whatever I want inside.</p>
<p dir="auto">Looks like your example is perfect cincirin, could you please tell me with 2 lines of codes how you acheieved that?<br />
Can you move these two QLabels?<br />
I cant figure how to access the handle by the QSlider class ....</p>
]]></description><link>https://forum.qt.io/post/213388</link><guid isPermaLink="true">https://forum.qt.io/post/213388</guid><dc:creator><![CDATA[BlackMamba]]></dc:creator><pubDate>Tue, 04 Feb 2014 09:43:18 GMT</pubDate></item><item><title><![CDATA[Reply to Subclassing QSlider with handle as a Widget on Tue, 04 Feb 2014 08:23:34 GMT]]></title><description><![CDATA[<p dir="auto">Yes, is perfectly doable by subclassing QSlider.<br />
See my slider implementation for example :<br />
!<a href="http://s22.postimg.org/4c9p4p0qp/Slider.png" target="_blank" rel="noopener noreferrer nofollow ugc">http://s22.postimg.org/4c9p4p0qp/Slider.png</a>(my Slider)!</p>
<p dir="auto">The two green areas are two QLabels</p>
<p dir="auto">edit: Andre was faster :-)</p>
]]></description><link>https://forum.qt.io/post/213373</link><guid isPermaLink="true">https://forum.qt.io/post/213373</guid><dc:creator><![CDATA[cincirin]]></dc:creator><pubDate>Tue, 04 Feb 2014 08:23:34 GMT</pubDate></item><item><title><![CDATA[Reply to Subclassing QSlider with handle as a Widget on Tue, 04 Feb 2014 08:23:12 GMT]]></title><description><![CDATA[<p dir="auto">It depends what you want to achieve exactly. If you subclass, you also inherit the complete API and thus the identity of QSlider. That is, your new widget will <em>be</em> a slider, for all practical purposes. If you don't want that, consider using QStyle to just render the parts of the slider that you need instead.</p>
]]></description><link>https://forum.qt.io/post/213372</link><guid isPermaLink="true">https://forum.qt.io/post/213372</guid><dc:creator><![CDATA[andre]]></dc:creator><pubDate>Tue, 04 Feb 2014 08:23:12 GMT</pubDate></item></channel></rss>