Range slider in Qt (two handles in a QSlider)

Sivam picture Sivam · Jun 28, 2013 · Viewed 15.6k times · Source

I am using Visual Studio 2010 with Qt 5.0.1 integrated. I need a range selection in QSlider. Is it possible to get two handles?

Below is an image illustrating what I need.

Example Image

Answer

AmusingTeebs picture AmusingTeebs · Sep 24, 2014

I had the exact same problem. I thought about using the QxtSpanSlider, and although they have beautiful code, they don't keep their code up to date anymore. So, I decided to make my own. I haven't spent that much time on this, so there are kludges and probably bugs. However, it should be at a point to where you can copy/paste it into your project. I hope it'll point you in the right direction.

*note, before you use this, here is a list of all of the problems I've found and am currently working on:

  • The second handle isn't nearly as sensitive as the first handle, resulting in slight agitation for the user.
  • Some of the values are hard coded and as a result the slider isn't as dynamic as it could be.
  • The second handle doesn't handle (haa...) negative values yet.