Home | All Classes | Main Classes | Annotated | Grouped Classes | Functions |

# QSlider Class Reference

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

    #include <QSlider>

Inherits QAbstractSlider.

- List of all members, including inherited members
- Compatibility members

### Public Types

- enum TickSetting { NoTickMarks, TickMarksBoth, TickMarksAbove, TickMarksBelow, TickMarksLeft, TickMarksRight }

### Writable Properties

- tickInterval : int
- tickmarks : TickSetting

- 10 writable properties inherited from QAbstractSlider
- 33 writable properties inherited from QWidget
- 1 writable property inherited from QObject

### Read-Only Properties

- 24 read-only properties inherited from QWidget

### Public Functions

- QSlider ( QWidget * parent = 0 )
- QSlider ( Qt::Orientation orientation, QWidget * parent = 0 )
- ~QSlider ()

- 4 public functions inherited from QAbstractSlider
- 83 public functions inherited from QWidget
- 24 public functions inherited from QObject
- 2 public functions inherited from QPaintDevice

### Public Slots

- 1 public slot inherited from QAbstractSlider
- 16 public slots inherited from QWidget
- 1 public slot inherited from QObject

### Signals

- 6 signals inherited from QAbstractSlider
- 1 signal inherited from QObject

### Static Public Members

- 4 static public members inherited from QWidget
- 4 static public members inherited from QObject

### Protected Functions

- 3 protected functions inherited from QAbstractSlider
- 44 protected functions inherited from QWidget
- 9 protected functions inherited from QObject

## 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 setTickmarks() to indicate where you want the tickmarks to be, setTickInterval() to indicate how many of them you want.

QSlider inherits a comprehensive set of signals:

Signal | Emitted when
--- | ---
valueChanged() | the slider's 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.

QSlider only provides integer ranges. Note that although QSlider handles very large numbers, it becomes difficult for users to effectivley use a slider 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).

GUI Design Handbook: Slider

See also QScrollBar and QSpinBox.

## Member Type Documentation

### enum QSlider::TickSetting

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

`QSlider::NoTickMarks` | do not draw any tickmarks.
`QSlider::TickMarksBoth` | draw tickmarks on both sides of the groove.
`QSlider::TickMarksAbove` | draw tickmarks above the (horizontal) slider
`QSlider::TickMarksBelow` | draw tickmarks below the (horizontal) slider
`QSlider::TickMarksLeft` | draw tickmarks to the left of the (vertical) slider
`QSlider::TickMarksRight` | draw tickmarks to the right of the (vertical) slider

## Property Documentation

### tickInterval : int

This property holds the interval between tickmarks.

This is a value interval, not a pixel interval. If it is 0, the slider will choose between lineStep() and pageStep(). The initial value of tickInterval is 0.

Access functions:

- int tickInterval () const
- void setTickInterval ( int ti )

See also QRangeControl::lineStep() and QRangeControl::pageStep().

### tickmarks : TickSetting

This property holds the tickmark settings for this slider.

The valid values are in QSlider::TickSetting. The default is `NoMarks`.

Access functions:

- TickSetting tickmarks () const
- void setTickmarks ( TickSetting ts )

See also tickInterval.

## Member Function Documentation

### QSlider::QSlider ( QWidget * parent = 0 )

Constructs a vertical slider.

The parent argument is sent to the QAbstractSlider constructor.

### QSlider::QSlider ( Qt::Orientation orientation, QWidget * parent = 0 )

Constructs a slider.

The orientation must be Qt::Vertical or Qt::Horizontal.

The parent argument is sent on to the QAbstractSlider constructor.

### QSlider::~QSlider ()

Destructor.