3

I need to draw a slider in Qt which accepts a value of double/float data type, and also display the label value corresponding to the slider value. The default QSlider from Qt can only accept integer data type as the value and it doesn't display the label value. I then tried to browse on google and found a library called Qwt, and this library has a class called QwtSlider. The documentation also says that it does accept a float/double data type (as I expected). So far so good.

The Qwt documentation and screenshot on this link (http://qwt.sourceforge.net/controlscreenshots.html) shows that this library can display the value label next to the slider.

I tried to code as follow:

QwtSlider *slider = new QwtSlider(this);
slider->setValue (0.5);
slider->setRange(0.0, 1.0);
slider->setStep (0.01);

however this slider widget didn't show any value label. I tried to browse the Qwt documentation but I couldn't figure out how to display the value label as shown in the screenshot. The slider pointer points to the middle of the slider scale (as expected), but no label is shown.

Does anyone has a clue on this?

all_by_grace
  • 2,315
  • 6
  • 37
  • 52

1 Answers1

0

According to the documentation for the QwtSlider constructor, since you aren't specifying a value for ScalePos, it is defaulting to NoScale. You should try specifying a value for that.

Arnold Spence
  • 21,942
  • 7
  • 74
  • 67