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.
setHandleLabelPositionmoves the handle labels: above (LabelPosition.LabelsAbove, the default), below, on the handles (LabelPosition.LabelsOnHandle), or nowhere (LabelPosition.NoLabel).setEdgeLabelModesets 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.
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.
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.EdgeLabelModeLabelIsRange,LabelIsValueQLabeledRangeSlider.LabelPositionNoLabel,LabelsAbove,LabelsBelow,LabelsOnHandle
Properties¶
barColor
¶
The color of the bar between the first and last handle.
Methods¶
expandRangeOnHandleEdit
¶
expandRangeOnHandleEdit() -> bool
Return whether out-of-range handle edits expand the slider range.
handleLabelPosition
¶
Return where/whether labels are shown adjacent to slider handles.
setEdgeLabelMode
¶
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
¶
Set where/whether labels are shown adjacent to slider handles.
setOrientation
¶
Set orientation, value will be 'horizontal' or 'vertical'.