Home · Overviews · Examples 

QSlider Class Reference
[com.trolltech.qt.gui module]

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

Inherits QAbstractSlider.


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:

SignalDescription
valueChangedEmitted when the slider's value has changed. The tracking() determines whether this signal is emitted during user interaction.
sliderPressedEmitted when the user starts to drag the slider.
sliderMovedEmitted when the user drags the slider.
sliderReleasedEmitted 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:

Screenshot of a Macintosh sliderA slider shown in the Macintosh widget style.
Screenshot of a Windows XP sliderA slider shown in the Windows XP widget style.
Screenshot of a Plastique sliderA slider shown in the Plastique widget style.

See also QScrollBar, QSpinBox, QDial, GUI Design Handbook: Slider, and Sliders Example.


Copyright © 2008 Trolltech Trademarks
Qt Jambi 4.3.4_01