Lily
Lily

Reputation: 846

Displaying minimum and maximum value for slider in Pyside

so I have a slider that has the range 2.5 to 20

I would like to add on the left of the slider 2.5 and on the right 20 so the user know what is the range

another thing I would like to display the value while the user changing the slider

here what I have so far

        sld = QtGui.QSlider(QtCore.Qt.Horizontal, window2)
        sld.setRange(2.5, 30)
        sld.setGeometry(30, 20, 200, 30)

Upvotes: 1

Views: 3579

Answers (1)

LozzerJP
LozzerJP

Reputation: 856

I would suggest you just build a new composite widget out of the following:

  1. a label widget at the top displaying the value from the slider => sld.value()
  2. a label widget on the left showing the minimum value => sld.minimum()
  3. the slider itself.
  4. a label widget on the right showing the minimum value => sld.maximum()

Just arrange these using a horizontal layout (for 2, 3, 4) inside a vertical layout (for 1 + the horizontal layout), and things will work great.

Hope that helps.

Upvotes: 2

Related Questions