|  | Home · All Classes · Modules

# QSlider Class Reference
[QtGui module]

The QSlider widget provides a vertical or horizontal slider. More...

Inherits QAbstractSlider.

### Types

- enum TickPosition { NoTicks, TicksAbove, TicksLeft, TicksBelow, TicksRight, TicksBothSides }

### Methods

- __init__ (self, QWidget parent = None)
- __init__ (self, Qt.Orientation orientation, QWidget parent = None)
- bool event (self, QEvent event)
- initStyleOption (self, QStyleOptionSlider option)
- QSize minimumSizeHint (self)
- mouseMoveEvent (self, QMouseEvent ev)
- mousePressEvent (self, QMouseEvent ev)
- mouseReleaseEvent (self, QMouseEvent ev)
- paintEvent (self, QPaintEvent ev)
- setTickInterval (self, int ti)
- setTickPosition (self, TickPosition position)
- QSize sizeHint (self)
- int tickInterval (self)
- TickPosition tickPosition (self)

## Detailed Description

The QSlider widget provides a vertical or horizontal slider.

The slider is the classic widget for controlling a bounded value. It lets the user move a slider handle along a horizontal or vertical groove and translates the handle's position into an integer value within the legal range.

QSlider has very few of its own functions; most of the functionality is in QAbstractSlider. The most useful functions are setValue() to set the slider directly to some value; triggerAction() to simulate the effects of clicking (useful for shortcut keys); setSingleStep(), setPageStep() to set the steps; and setMinimum() and setMaximum() to define the range of the scroll bar.

QSlider provides methods for controlling tickmarks. You can use setTickPosition() to indicate where you want the tickmarks to be, setTickInterval() to indicate how many of them you want. the currently set tick position and interval can be queried using the tickPosition() and tickInterval() functions, respectively.

QSlider inherits a comprehensive set of signals:

Signal | Description
--- | ---
valueChanged() | Emitted when the slider's value has changed. The tracking() determines whether this signal is emitted during user interaction.
sliderPressed() | Emitted when the user starts to drag the slider.
sliderMoved() | Emitted when the user drags the slider.
sliderReleased() | Emitted when the user releases the slider.

QSlider only provides integer ranges. Note that although QSlider handles very large numbers, it becomes difficult for users to use a slider accurately for very large ranges.

A slider accepts focus on Tab and provides both a mouse wheel and a keyboard interface. The keyboard interface is the following:

- Left/Right move a horizontal slider by one single step.
- Up/Down move a vertical slider by one single step.
- PageUp moves up one page.
- PageDown moves down one page.
- Home moves to the start (mininum).
- End moves to the end (maximum).

| A slider shown in the Macintosh widget style.
| A slider shown in the Windows XP widget style.
| A slider shown in the Plastique widget style.

## Type Documentation

### QSlider.TickPosition

This enum specifies where the tick marks are to be drawn relative to the slider's groove and the handle the user moves.

Constant | Value | Description
--- | --- | ---
`QSlider.NoTicks` | `0` | Do not draw any tick marks.
`QSlider.TicksBothSides` | `3` | Draw tick marks on both sides of the groove.
`QSlider.TicksAbove` | `1` | Draw tick marks above the (horizontal) slider
`QSlider.TicksBelow` | `2` | Draw tick marks below the (horizontal) slider
`QSlider.TicksLeft` | `TicksAbove` | Draw tick marks to the left of the (vertical) slider
`QSlider.TicksRight` | `TicksBelow` | Draw tick marks to the right of the (vertical) slider

## Method Documentation

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

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

Constructs a vertical slider with the given parent.

### QSlider.__init__ (self, Qt.Orientation orientation, QWidget parent = None)

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

Constructs a slider with the given parent. The orientation parameter determines whether the slider is horizontal or vertical; the valid values are Qt.Vertical and Qt.Horizontal.

### bool QSlider.event (self, QEvent event)

Reimplemented from QObject.event().

### QSlider.initStyleOption (self, QStyleOptionSlider option)

Initialize option with the values from this QSlider. This method is useful for subclasses when they need a QStyleOptionSlider, but don't want to fill in all the information themselves.

See also QStyleOption.initFrom().

### QSize QSlider.minimumSizeHint (self)

Reimplemented from QWidget.minimumSizeHint().

### QSlider.mouseMoveEvent (self, QMouseEvent ev)

Reimplemented from QWidget.mouseMoveEvent().

### QSlider.mousePressEvent (self, QMouseEvent ev)

Reimplemented from QWidget.mousePressEvent().

### QSlider.mouseReleaseEvent (self, QMouseEvent ev)

Reimplemented from QWidget.mouseReleaseEvent().

### QSlider.paintEvent (self, QPaintEvent ev)

Reimplemented from QWidget.paintEvent().

### QSlider.setTickInterval (self, int ti)

### QSlider.setTickPosition (self, TickPosition position)

### QSize QSlider.sizeHint (self)

Reimplemented from QWidget.sizeHint().

### int QSlider.tickInterval (self)

### TickPosition QSlider.tickPosition (self)