0

I'm creating a Custom Multi Slider, I have already created the slider with multiple handles on it. This is what it currently looks like:

enter image description here

As you can see 3 handles. But see that bar in the middle? I need that to sit between the two alternate sliders - but for some reason it just keeps offsetting to the right slightly :(.

I've tried searching for this, and I don't want to use pre-made multi-sliders can anyone help me?

This is the code that deals with Moving my middle slider around:

auto slider_min(ui->slider_multi_slider->minimum());
auto slider_max(ui->slider_multi_slider->maximum());
auto slider_size_px(ui->slider_multi_slider->size().width());


auto end(ui->slider_multi_slider->endHandleValue());
auto start(ui->slider_multi_slider->startHandleValue());
auto diff(end - start);
auto mid(start + (diff/2));

auto start_x_pos(QStyle::sliderPositionFromValue(slider_min,slider_max,start,slider_size_px));
auto end_x_pos(QStyle::sliderPositionFromValue(slider_min,slider_max,end,slider_size_px));
auto mid_x_pos(QStyle::sliderPositionFromValue(slider_min,slider_max,mid,slider_size_px));

auto diff_x_pos(end_x_pos - start_x_pos);

ui->slider_multi_slider->setValue(mid);

slider_style = new SliderProxyStyle();
slider_style->setWidth(diff_x_pos);
ui->slider_multi_slider->setStyle(slider_style);
svlasov
  • 9,923
  • 2
  • 38
  • 39
Jake Wade
  • 571
  • 3
  • 19
  • Thanks @Jonathan Mee - For editing my text, grammar Is not my strong suit , any thoughts on the question though? – Jake Wade Feb 25 '15 at 15:12
  • Sadly I don't have any wisdom for you. I was hoping that cleaning the question up might help someone else answer it, cause I am curious. – Jonathan Mee Feb 25 '15 at 15:15
  • Even more Edits loving it, but not loving the amount of solutions aha :( I have only been on stack overflow for a month still working on my format and what not thanks for the edits – Jake Wade Feb 25 '15 at 15:49
  • How does it look without SliderProxyStyle? How is it implemented? – svlasov Feb 25 '15 at 17:15
  • Without the SliderProxyStyle it would look like an normal QSlider::Handler which you cant change the size of without overwriting it with a SliderProxy – Jake Wade Feb 26 '15 at 08:32

0 Answers0