Three Position Switch

+1 for the implementation using the Slider class.

Also, you could achieve the "discrete positions" feel by setting the interval in your setRange() call, i. e.

slider->setRange (0.0, 2.0, 1.0)

will give you a slider whose values will always be 0.0, 1.0 or 2.0 no matter how dragged/clicked, and the "thumb" of the slider will be discretely positioned at the left/middle/right position as well