Home · All Classes · Main Classes · Grouped Classes · Modules · Functions

QSlider Class Reference
[QtGui module]

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

 #include <QSlider>

Inherits QAbstractSlider.

Public Types

Properties

Public Functions

Additional Inherited Members


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
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:

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.


Member Type Documentation

enum 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.

ConstantValueDescription
QSlider::NoTicks0Do not draw any tick marks.
QSlider::TicksBothSides3Draw tick marks on both sides of the groove.
QSlider::TicksAbove1Draw tick marks above the (horizontal) slider
QSlider::TicksBelow2Draw tick marks below the (horizontal) slider
QSlider::TicksLeftTicksAboveDraw tick marks to the left of the (vertical) slider
QSlider::TicksRightTicksBelowDraw tick marks 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 default value is 0.

Access functions:

See also tickPosition, lineStep(), and pageStep().

tickPosition : TickPosition

This property holds the tickmark position for this slider.

The valid values are described by the QSlider::TickPosition enum.

The default value is QSlider::NoTicks.

Access functions:

See also tickInterval.


Member Function Documentation

QSlider::QSlider ( QWidget * parent = 0 )

Constructs a vertical slider with the given parent.

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

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.

QSlider::~QSlider ()

Destroys this slider.


Member Function Documentation

QSlider::QSlider ( QWidget * parent, const char * name )

Use QSlider() and QObject::setObjectName() instead.

For example, if you have code like

 QSlider *mySlider = new QSlider(parent, name);

you can rewrite it as

 QSlider *mySlider = new QSlider(parent);
 mySlider->setObjectName(name);

QSlider::QSlider ( Qt::Orientation orientation, QWidget * parent, const char * name )

Use QSlider() and QObject::setObjectName() instead.

For example, if you have code like

 QSlider *mySlider = new QSlider(orientation, parent, name);

you can rewrite it as

 QSlider *mySlider = new QSlider(orientation, parent);
 mySlider->setObjectName(name);

QSlider::QSlider ( int minValue, int maxValue, int pageStep, int value, Qt::Orientation orientation, QWidget * parent = 0, const char * name = 0 )

Use QSlider(), QObject::setObjectName() and the functionality inherited from QAbstractSlider instead.

For example, if you have code like

 QSlider *mySlider = new QSlider(minValue, maxValue, pageStep,
                                 value, orientation, parent, name);

you can rewrite it as

 QSlider *mySlider = new QSlider(orientation, parent);
 mySlider->setObjectName(name);
 mySlider->setMinimum(minValue);
 mySlider->setMaximum(maxValue);
 mySlider->setPageStep(pageStep);
 mySlider->setValue(value);

void QSlider::addStep ()   [slot]

Use setValue() instead.

void QSlider::setTickmarks ( TickPosition position )

Use setTickPosition() instead.

See also tickmarks().

void QSlider::subtractStep ()   [slot]

Use setValue() instead.

TickPosition QSlider::tickmarks () const

Use tickPosition() instead.

See also setTickmarks().


Copyright © 2007 Trolltech Trademarks
Qt 4.2.3