|  | Home · All Classes · Modules

# QAbstractSlider Class Reference
[QtGui module]

The QAbstractSlider class provides an integer value within a range. More...

Inherits QWidget.

Inherited by QDial, QScrollBar and QSlider.

### Types

- enum SliderAction { SliderNoAction, SliderSingleStepAdd, SliderSingleStepSub, SliderPageStepAdd, ..., SliderMove }
- enum SliderChange { SliderRangeChange, SliderOrientationChange, SliderStepsChange, SliderValueChange }

### Methods

- __init__ (self, QWidget parent = None)
- changeEvent (self, QEvent e)
- bool event (self, QEvent e)
- bool hasTracking (self)
- bool invertedAppearance (self)
- bool invertedControls (self)
- bool isSliderDown (self)
- keyPressEvent (self, QKeyEvent ev)
- int maximum (self)
- int minimum (self)
- Qt.Orientation orientation (self)
- int pageStep (self)
- SliderAction repeatAction (self)
- setInvertedAppearance (self, bool)
- setInvertedControls (self, bool)
- setMaximum (self, int)
- setMinimum (self, int)
- setOrientation (self, Qt.Orientation)
- setPageStep (self, int)
- setRange (self, int min, int max)
- setRepeatAction (self, SliderAction action, int thresholdTime = 500, int repeatTime = 50)
- setSingleStep (self, int)
- setSliderDown (self, bool)
- setSliderPosition (self, int)
- setTracking (self, bool enable)
- setValue (self, int)
- int singleStep (self)
- sliderChange (self, SliderChange change)
- int sliderPosition (self)
- timerEvent (self, QTimerEvent)
- triggerAction (self, SliderAction action)
- int value (self)
- wheelEvent (self, QWheelEvent e)

### Qt Signals

- void actionTriggered (int)
- void rangeChanged (int,int)
- void sliderMoved (int)
- void sliderPressed ()
- void sliderReleased ()
- void valueChanged (int)

## Detailed Description

The QAbstractSlider class provides an integer value within a range.

The class is designed as a common super class for widgets like QScrollBar, QSlider and QDial.

Here are the main properties of the class:

1. value: The bounded integer that QAbstractSlider maintains.
2. minimum: The lowest possible value.
3. maximum: The highest possible value.
4. singleStep: The smaller of two natural steps that an abstract sliders provides and typically corresponds to the user pressing an arrow key.
5. pageStep: The larger of two natural steps that an abstract slider provides and typically corresponds to the user pressing PageUp or PageDown.
6. tracking: Whether slider tracking is enabled.
7. sliderPosition: The current position of the slider. If tracking is enabled (the default), this is identical to value.

Unity (1) may be viewed as a third step size. setValue() lets you set the current value to any integer in the allowed range, not just minimum() + n * singleStep() for integer values of n. Some widgets may allow the user to set any value at all; others may just provide multiples of singleStep() or pageStep().

QAbstractSlider emits a comprehensive set of signals:

Signal | Emitted when
--- | ---
valueChanged() | the value has changed. The tracking determines whether this signal is emitted during user interaction.
sliderPressed() | the user starts to drag the slider.
sliderMoved() | the user drags the slider.
sliderReleased() | the user releases the slider.
actionTriggered() | a slider action was triggerd.
rangeChanged() | a the range has changed.

QAbstractSlider provides a virtual sliderChange() function that is well suited for updating the on-screen representation of sliders. By calling triggerAction(), subclasses trigger slider actions. Two helper functions QStyle.sliderPositionFromValue() and QStyle.sliderValueFromPosition() help subclasses and styles to map screen coordinates to logical range values.

## Type Documentation

### QAbstractSlider.SliderAction

Constant | Value
--- | ---
`QAbstractSlider.SliderNoAction` | `0`
`QAbstractSlider.SliderSingleStepAdd` | `1`
`QAbstractSlider.SliderSingleStepSub` | `2`
`QAbstractSlider.SliderPageStepAdd` | `3`
`QAbstractSlider.SliderPageStepSub` | `4`
`QAbstractSlider.SliderToMinimum` | `5`
`QAbstractSlider.SliderToMaximum` | `6`
`QAbstractSlider.SliderMove` | `7`

### QAbstractSlider.SliderChange

Constant | Value
--- | ---
`QAbstractSlider.SliderRangeChange` | `0`
`QAbstractSlider.SliderOrientationChange` | `1`
`QAbstractSlider.SliderStepsChange` | `2`
`QAbstractSlider.SliderValueChange` | `3`

## Method Documentation

### QAbstractSlider.__init__ (self, QWidget parent = None)

The parent argument, if not None, causes self to be owned by Qt instead of PyQt.

Constructs an abstract slider.

The parent argument is sent to the QWidget constructor.

The minimum defaults to 0, the maximum to 99, with a singleStep size of 1 and a pageStep size of 10, and an initial value of 0.

### QAbstractSlider.changeEvent (self, QEvent e)

Reimplemented from QWidget.changeEvent().

### bool QAbstractSlider.event (self, QEvent e)

Reimplemented from QObject.event().

### bool QAbstractSlider.hasTracking (self)

### bool QAbstractSlider.invertedAppearance (self)

### bool QAbstractSlider.invertedControls (self)

### bool QAbstractSlider.isSliderDown (self)

### QAbstractSlider.keyPressEvent (self, QKeyEvent ev)

Reimplemented from QWidget.keyPressEvent().

### int QAbstractSlider.maximum (self)

### int QAbstractSlider.minimum (self)

### Qt.Orientation QAbstractSlider.orientation (self)

### int QAbstractSlider.pageStep (self)

### SliderAction QAbstractSlider.repeatAction (self)

Returns the current repeat action.

See also setRepeatAction().

### QAbstractSlider.setInvertedAppearance (self, bool)

### QAbstractSlider.setInvertedControls (self, bool)

### QAbstractSlider.setMaximum (self, int)

### QAbstractSlider.setMinimum (self, int)

### QAbstractSlider.setOrientation (self, Qt.Orientation)

This method is also a Qt slot with the C++ signature `void setOrientation( ::Qt::Orientation)`.

### QAbstractSlider.setPageStep (self, int)

### QAbstractSlider.setRange (self, int min, int max)

Sets the slider's minimum to min and its maximum to max.

If max is smaller than min, min becomes the only legal value.

See also minimum and maximum.

### QAbstractSlider.setRepeatAction (self, SliderAction action, int thresholdTime = 500, int repeatTime = 50)

Sets action action to be triggered repetitively in intervals of repeatTime, after an initial delay of thresholdTime.

See also triggerAction() and repeatAction().

### QAbstractSlider.setSingleStep (self, int)

### QAbstractSlider.setSliderDown (self, bool)

### QAbstractSlider.setSliderPosition (self, int)

### QAbstractSlider.setTracking (self, bool enable)

### QAbstractSlider.setValue (self, int)

This method is also a Qt slot with the C++ signature `void setValue(int)`.

### int QAbstractSlider.singleStep (self)

### QAbstractSlider.sliderChange (self, SliderChange change)

Reimplement this virtual function to track slider changes such as SliderRangeChange, SliderOrientationChange, SliderStepsChange, or SliderValueChange. The default implementation only updates the display and ignores the change parameter.

### int QAbstractSlider.sliderPosition (self)

### QAbstractSlider.timerEvent (self, QTimerEvent)

Reimplemented from QObject.timerEvent().

### QAbstractSlider.triggerAction (self, SliderAction action)

Triggers a slider action. Possible actions are SliderSingleStepAdd, SliderSingleStepSub, SliderPageStepAdd, SliderPageStepSub, SliderToMinimum, SliderToMaximum, and SliderMove.

See also actionTriggered().

### int QAbstractSlider.value (self)

### QAbstractSlider.wheelEvent (self, QWheelEvent e)

Reimplemented from QWidget.wheelEvent().

## Qt Signal Documentation

### void actionTriggered (int)

This is the default overload of this signal.

This signal is emitted when the slider action action is triggered. Actions are SliderSingleStepAdd, SliderSingleStepSub, SliderPageStepAdd, SliderPageStepSub, SliderToMinimum, SliderToMaximum, and SliderMove.

When the signal is emitted, the sliderPosition has been adjusted according to the action, but the value has not yet been propagated (meaning the valueChanged() signal was not yet emitted), and the visual display has not been updated. In slots connected to this signal you can thus safely adjust any action by calling setSliderPosition() yourself, based on both the action and the slider's value.

See also triggerAction().

### void rangeChanged (int,int)

This is the default overload of this signal.

This signal is emitted when the slider range has changed, with min being the new minimum, and max being the new maximum.

See also minimum and maximum.

### void sliderMoved (int)

This is the default overload of this signal.

This signal is emitted when sliderDown is true and the slider moves. This usually happens when the user is dragging the slider. The value is the new slider position.

This signal is emitted even when tracking is turned off.

See also setTracking(), valueChanged(), isSliderDown(), sliderPressed(), and sliderReleased().

### void sliderPressed ()

This is the default overload of this signal.

This signal is emitted when the user presses the slider with the mouse, or programmatically when setSliderDown(true) is called.

See also sliderReleased(), sliderMoved(), and isSliderDown().

### void sliderReleased ()

This is the default overload of this signal.

This signal is emitted when the user releases the slider with the mouse, or programmatically when setSliderDown(false) is called.

See also sliderPressed(), sliderMoved(), and sliderDown.

### void valueChanged (int)

This is the default overload of this signal.

This signal is emitted when the slider value has changed, with the new slider value as argument.