QDoubleRangeSlider¶
A QRangeSlider for float values: its range, values, and
steps are floats. See the QRangeSlider page for how range sliders work.
from qtpy.QtCore import Qt
from qtpy.QtWidgets import QApplication
from superqt import QDoubleRangeSlider
app = QApplication([])
slider = QDoubleRangeSlider(Qt.Orientation.Horizontal)
slider.setRange(0, 1)
slider.setValue((0.2, 0.8))
slider.show()
app.exec()
Subclass of QSlider
QDoubleRangeSlider inherits all of QSlider's methods, signals, and properties. Only those that superqt adds or changes are listed here.
Signals¶
valuesChanged(tuple): Emitted when the slider value has changed, with the new slider valuesslidersMoved(tuple): Emitted when sliderDown is true and the slider moves. This usually happens when the user is dragging the slider. The value is the positions of all handles.fvalueChanged(float)fsliderMoved(float)frangeChanged(float, float)
Properties¶
barColor
¶
The color of the bar between the first and last handle.
Methods¶
applyMacStylePatch
¶
Apply a QSS patch to fix sliders on macos>=12 with QT < 6.
see FAQ for more details.
barIsRigid
¶
barIsRigid() -> bool
Whether bar length is constant when dragging the bar.
If False, the bar can shorten when dragged beyond min/max. Default is True.
barMovesAllHandles
¶
barMovesAllHandles() -> bool
Whether clicking on the bar moves all handles, or just the nearest.
setBarIsRigid
¶
setBarIsRigid(val: bool = True) -> None
Whether bar length is constant when dragging the bar.
If False, the bar can shorten when dragged beyond min/max. Default is True.
setBarMovesAllHandles
¶
setBarMovesAllHandles(val: bool = True) -> None
Whether clicking on the bar moves all handles, or just the nearest.
setBarVisible
¶
setBarVisible(val: bool = True) -> None
Whether to show the bar between the first and last handle.
setSliderPosition
¶
setSliderPosition(
pos: float | Sequence[float],
index: int | None = None,
*,
reversed: bool = False,
) -> None
Set current position of the handles with a sequence of integers.
Parameters:
-
pos(Union[float, Sequence[float]]) –The new position of the slider handle(s). If a sequence, it must have the same length as
value(). If it is a scalar, index will be used to set the position of the handle at that index. -
index(int | None, default:None) –The index of the handle to set the position of. If None, the "pressedIndex" will be used.
-
reversed(bool, default:False) –Order in which to set the positions. Can be useful when setting multiple positions, to avoid intermediate overlapping values.
sliderPosition
¶
Get current value of the widget as a tuple of integers.
If tracking is enabled (the default) this will be identical to value().