Skip to content

QLabeledRangeSlider

A QRangeSlider with labels: one above each handle, with its value, and one at each end, with the minimum and maximum. A value typed into a handle's label moves that handle, and a value typed into an end label changes the minimum or maximum.

  • setHandleLabelPosition moves the handle labels: above (LabelPosition.LabelsAbove, the default), below, on the handles (LabelPosition.LabelsOnHandle), or nowhere (LabelPosition.NoLabel).
  • setEdgeLabelMode sets what the end labels show: the range (EdgeLabelMode.LabelIsRange, the default), the values of the first and last handles (EdgeLabelMode.LabelIsValue; then typing into them moves those handles), or nothing (EdgeLabelMode.NoLabel).
  • With setExpandRangeOnHandleEdit(True), typing a value outside of the range into a handle's label expands the range to include it.
QLabeledRangeSlider QLabeledRangeSlider
from qtpy.QtCore import Qt
from qtpy.QtWidgets import QApplication

from superqt import QLabeledRangeSlider

app = QApplication([])

slider = QLabeledRangeSlider(Qt.Orientation.Horizontal)
slider.setValue((20, 80))
slider.show()

app.exec()

Fine-tuning the label positions

The label_shift_x and label_shift_y attributes offset the handle labels by that many pixels.

QLabeledRangeSlider

QLabeledRangeSlider(parent: QWidget | None = ...)
QLabeledRangeSlider(
    orientation: Orientation, parent: QWidget | None = ...
)

Subclass of QAbstractSlider

QLabeledRangeSlider inherits all of QAbstractSlider's methods, signals, and properties. Only those that superqt adds or changes are listed here.

Signals

  • valuesChanged(tuple)
  • editingFinished()
  • frangeChanged(float, float)

Enums

QLabeledRangeSlider.EdgeLabelMode
LabelIsRange, LabelIsValue
QLabeledRangeSlider.LabelPosition
NoLabel, LabelsAbove, LabelsBelow, LabelsOnHandle

Properties

barColor

barColor = Property(
    QtGui.QBrush, _getBarColor, _setBarColor
)

The color of the bar between the first and last handle.

Methods

edgeLabelMode

edgeLabelMode() -> EdgeLabelMode

Return current EdgeLabelMode.

expandRangeOnHandleEdit

expandRangeOnHandleEdit() -> bool

Return whether out-of-range handle edits expand the slider range.

handleLabelPosition

handleLabelPosition() -> LabelPosition

Return where/whether labels are shown adjacent to slider handles.

setEdgeLabelMode

setEdgeLabelMode(opt: EdgeLabelMode) -> None

Set EdgeLabelMode, controls what is shown at the min/max labels.

setExpandRangeOnHandleEdit

setExpandRangeOnHandleEdit(expand: bool) -> None

Set whether out-of-range handle edits expand the slider range.

When enabled, typing a value above a handle that is outside the current slider range will expand the corresponding range edge and then set the handle to the entered value.

setHandleLabelPosition

setHandleLabelPosition(opt: LabelPosition) -> None

Set where/whether labels are shown adjacent to slider handles.

setInvertedAppearance

setInvertedAppearance(a0: bool) -> None

setOrientation

setOrientation(orientation: Orientation) -> None

Set orientation, value will be 'horizontal' or 'vertical'.

setRange

setRange(min: int, max: int) -> None

setTickInterval

setTickInterval(interval: int) -> None

setTickPosition

setTickPosition(pos: TickPosition) -> None

tickInterval

tickInterval() -> int

tickPosition

tickPosition() -> TickPosition