Skip to main content
`Ctrl`+`K`

# `RangeSlider`: Slider to define an interval

This module provides a `RangeSlider` widget.

class StyleOptionRangeSlider

class RangeSlider(parent=None)

  Range slider with 2 thumbs and an optional colored groove.

  The position of the slider thumbs can be retrieved either as values in the slider range or as a number of steps or pixels.

  Parameters:

    parent (QWidget) – See QWidget

  sigRangeChanged

    Signal emitted when the value range has changed.

    It provides the new range (min, max).

  sigValueChanged

    Signal emitted when the value of the sliders has changed.

    It provides the slider values (first, second).

  sigPositionCountChanged

    This signal is emitted when the number of steps has changed.

    It provides the new position count.

  sigPositionChanged

    Signal emitted when the position of the sliders has changed.

    It provides the slider positions in steps or pixels (first, second).

  event(self, a0: QEvent | None) → bool
  getPositionCount()

    Returns the number of positions.

    Return type:

      Union[int,None]

  setPositionCount(count)

    Set the number of positions.

    Slider values are eventually adjusted.

    Parameters:

      count (Union[int,None]) – Either the number of possible positions or None to allow any values.

    Raises:

      ValueError – If count <= 1

  getFirstPosition()

    Returns first slider position

    Return type:

      int

  setFirstPosition(position)

    Set the position of the first slider

    The position is adjusted to valid values

    Parameters:

      position (int)

  getSecondPosition()

    Returns second slider position

    Return type:

      int

  setSecondPosition(position)

    Set the position of the second slider

    The position is adjusted to valid values

    Parameters:

      position (int)

  getPositions()

    Returns slider positions (first, second)

    Return type:

      List[int]

  setPositions(first, second)

    Set the position of both sliders at once

    First is clipped to the slider range: [0, max]. Second is clipped to valid values: [first, max]

    Parameters:

      - first (int)

      - second (int)

  getMinimum()

    Returns the minimum value of the slider range

    Return type:

      float

  setMinimum(minimum)

    Set the minimum value of the slider range.

    It eventually adjusts maximum. Slider positions remains unchanged and slider values are modified.

    Parameters:

      minimum (float)

    Raises:

      ValueError –

  getMaximum()

    Returns the maximum value of the slider range

    Return type:

      float

  setMaximum(maximum)

    Set the maximum value of the slider range

    It eventually adjusts minimum. Slider positions remains unchanged and slider values are modified.

    Parameters:

      maximum (float)

    Raises:

      ValueError –

  getRange()

    Returns the range of values (min, max)

    Return type:

      List[float]

  setRange(minimum, maximum)

    Set the range of values.

    If maximum is lower than minimum, minimum is the only valid value. Slider positions remains unchanged and slider values are modified.

    Parameters:

      - minimum (float)

      - maximum (float)

    Raises:

      ValueError –

  getFirstValue()

    Returns the value of the first slider

    Return type:

      float

  setFirstValue(value)

    Set the value of the first slider

    Value is clipped to valid values.

    Parameters:

      value (float)

  getSecondValue()

    Returns the value of the second slider

    Return type:

      float

  setSecondValue(value)

    Set the value of the second slider

    Value is clipped to valid values.

    Parameters:

      value (float)

  getValues()

    Returns value of both sliders at once

    Returns:

      (first value, second value)

    Return type:

      List[float]

  setValues(first, second)

    Set values for both sliders at once

    First is clipped to the slider range: [minimum, maximum]. Second is clipped to valid values: [first, maximum]

    Parameters:

      - first (float)

      - second (float)

  getGroovePixmap()

    Returns the pixmap displayed in the slider groove if any.

    Return type:

      Union[QPixmap,None]

  setGroovePixmap(pixmap)

    Set the pixmap displayed in the slider groove.

    Parameters:

      pixmap (Union[QPixmap,None]) – The QPixmap to use or None to unset.

  setGroovePixmapFromProfile(profile, colormap=None)

    Set the pixmap displayed in the slider groove from histogram values.

    Parameters:

      - profile (Union[numpy.ndarray,None]) – 1D array of values to display

      - colormap (Union[Colormap,str]) – The colormap name or object to convert profile values to colors

  mousePressEvent(self, a0: QMouseEvent | None)
  mouseMoveEvent(self, a0: QMouseEvent | None)
  mouseReleaseEvent(self, a0: QMouseEvent | None)
  focusOutEvent(self, a0: QFocusEvent | None)
  keyPressEvent(self, a0: QKeyEvent | None)
  resizeEvent(self, a0: QResizeEvent | None)
  paintEvent(self, a0: QPaintEvent | None)
  sizeHint(self) → QSize
  classmethod drawRangeSliderBackground(painter, option, widget)

    Draw the background of the RangeSlider widget into the painter.

    Parameters:

      - painter (qt.QPainter) – A painter

      - option (StyleOptionRangeSlider) – Options to draw the widget

      - qt.QWidget – The widget which have to be drawn