Qt logo

QSlider Class Reference


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

#include <qslider.h>

Inherits QRangeControl and QWidget.

List of all member functions.

Public Members

Public Slots

Signals

Protected 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 along a horizontal or vertical groove, and translates the slider's position into an integer value in the legal range.

QSlider inherits QRangeControl, which provides the "integer" side of the slider. setRange() and value() are likely to be used by practically all slider users; see the QRangeControl documentation for information about the many other functions that class provides.

The main functions offered by the slider itself are tickmark and orientation control; you can use setTickmarks() to indicate where you want the tickmarks to be, setTickInterval() to indicate how many of them you want, and setOrientation() to indicate whether the slider is to e horizontal or vertical.

A slider has a default focusPolicy() of TabFocus, and a suitable keyboard interface.

See also: QScrollBar, QSpinBox and GUI Design Handbook: Slider

Examples: xform/xform.cpp


Member Type Documentation

QSlider::TickSetting

This enum specifies where the tick marks are to be drawn, relative to the slider's groove and the handle the user moves. The possible values are NoMarks (no tickmarks are drawn), Above, Below, Left, Right and Both.

NoMarks means to not draw any tickmarks; Both means to draw tickmarks on both sides of the groove. Above and Below mean to draw tickmarks above and below the (horizontal) slider. Left and Right mean to draw tickmarks to the left and right of the (vertical) slider.


Member Function Documentation

QSlider::QSlider(Orientationorientation, QWidget*parent, constchar*name=0)

Constructs a slider.

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

The parent and name arguments are sent to the QWidget constructor.

QSlider::QSlider(QWidget*parent, constchar*name=0)

Constructs a vertical slider.

The parent and name arguments are sent to the QWidget constructor.

QSlider::QSlider(intminValue, intmaxValue, intpageStep, intvalue, Orientationorientation, QWidget*parent, constchar*name=0)

Constructs a slider.

Arguments:

The parent and name arguments are sent to the QWidget constructor.

voidQSlider::addStep() [slot]

Moves the slider one pageStep() upwards.

voidQSlider::drawTicks(QPainter*p, constQColorGroup&g, intd, intw, inti=1)const [protected]

Using p, draws tickmarks at a distance of d from the edge of the widget, using w pixels and with an interval of i.

Setting the colorgroup is useful to reuse the code to draw a mask if the slider supports transparceny.

See also: setAutoMask() and updateMask().

voidQSlider::drawTicks(QPainter*p, intd, intw, inti=1)const [protected]

Using p, draws tickmarks at a distance of d from the edge of the widget, using w pixels and with an interval of i.

Do not reimplement this function, it's mainly there for compatibility reasons. It simply calls

drawTicks( QPainter *p, const QColorGroup& g, int d, int w, int i ) const

which is the right function to overload.

See also: colorGroup(), drawTicks(, QPainter, *p, const, QColorGroup&, g, int, d, int, w, int, i, ), const and paintSlider.

voidQSlider::drawWinGroove(QPainter*p, QCOORDc) [protected]

This function is obsolete. It is provided to keep old programs working. We strongly advise against using it in new code.

Draws the "groove" on which the slider moves, using the painter p. c gives the distance from the top (or left) edge of the widget to the center of the groove.

voidQSlider::focusInEvent(QFocusEvent*) [virtualprotected]

Handles focus in events for the slider.

Reimplemented from QWidget.

voidQSlider::focusOutEvent(QFocusEvent*) [virtualprotected]

Handles focus out events for the slider.

Reimplemented from QWidget.

voidQSlider::keyPressEvent(QKeyEvent*e) [virtualprotected]

Handles key press events for the slider.

Reimplemented from QWidget.

QSizeQSlider::minimumSizeHint()const [virtual]

Reimplemented for internal reasons; the API is not affected.

Reimplemented from QWidget.

voidQSlider::mouseMoveEvent(QMouseEvent*e) [virtualprotected]

Handles mouse move events for the slider.

Reimplemented from QWidget.

voidQSlider::mousePressEvent(QMouseEvent*e) [virtualprotected]

Handles mouse press events for the slider.

Reimplemented from QWidget.

voidQSlider::mouseReleaseEvent(QMouseEvent*) [virtualprotected]

Handles mouse release events for the slider.

Reimplemented from QWidget.

OrientationQSlider::orientation()const

Returns the slider orientation; QSlider::Vertical or QSlider::Horizontal.

See also: setOrientation().

voidQSlider::paintEvent(QPaintEvent*) [virtualprotected]

Handles paint events for the slider.

Reimplemented from QWidget.

voidQSlider::paintSlider(QPainter*p, constQColorGroup&g, constQRect&r) [virtualprotected]

Paints the slider button using painter p with size, a colorgroup and position given by r. Reimplement this function to change the look of the slider button.

Setting the colorgroup is useful to reuse the code to draw a mask if the slider supports transparceny.

See also: setAutoMask() and updateMask().

voidQSlider::rangeChange() [virtualprotected]

Implements the virtual QRangeControl function.

Reimplemented from QRangeControl.

voidQSlider::resizeEvent(QResizeEvent*) [virtualprotected]

Handles resize events for the slider.

Reimplemented from QWidget.

voidQSlider::setOrientation(Orientationorientation) [virtual]

Sets the slider orientation. The orientation must be QSlider::Vertical or QSlider::Horizontal.

See also: orientation().

voidQSlider::setPalette(constQPalette&p) [virtual]

Reimplements the virtual function QWidget::setPalette().

Sets the background color to the mid color for Motif style sliders.

voidQSlider::setTickInterval(inti) [virtual]

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

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

voidQSlider::setTickmarks(TickSettings) [virtual]

Sets the way tickmarks are displayed by the slider. s can take the following values:

The initial value is NoMarks.

See also: tickmarks() and setTickInterval().

voidQSlider::setTracking(boolenable) [virtual]

Enables slider tracking if enable is TRUE, or disables tracking if enable is FALSE.

If tracking is enabled (default), the slider emits the valueChanged() signal whenever the slider is being dragged. If tracking is disabled, the slider emits the valueChanged() signal when the user releases the mouse button (unless the value happens to be the same as before).

See also: tracking().

voidQSlider::setValue(intvalue) [virtualslot]

Makes QRangeControl::setValue() available as a slot.

Examples: xform/xform.cpp

QSizeQSlider::sizeHint()const [virtual]

Returns the recommended size of the slider.

Reimplemented from QWidget.

QSizePolicyQSlider::sizePolicy()const [virtual]

Specifies that this widget can use more, but is able to survive on less, space in the orientation() direction; and is fixed in the other direction.

Reimplemented from QWidget.

voidQSlider::sliderMoved(intvalue) [signal]

This signal is emitted when the slider is dragged, with the new slider value as an argument.

voidQSlider::sliderPressed() [signal]

This signal is emitted when the user presses the slider with the mouse.

QRectQSlider::sliderRect()const

Returns the slider handle rectangle. (The actual moving-around thing.).

voidQSlider::sliderReleased() [signal]

This signal is emitted when the user releases the slider with the mouse.

voidQSlider::subtractStep() [slot]

Moves the slider one pageStep() downwards.

intQSlider::thickness()const [virtualprotected]

Returns the number of pixels to use for the business part of the slider (i.e. the non-tickmark portion). The remaining space is shared equally between the tickmark regions. This function and sizeHint() are closely related; if you change one, you almost certainly have to change the other.

intQSlider::tickInterval()const

Returns the interval between tickmarks. Returns 0 if the slider chooses between pageStep() and lineStep().

See also: setTickInterval().

QSlider::TickSettingQSlider::tickmarks()const

Returns the tickmark settings for this slider.

See also: setTickmarks().

boolQSlider::tracking()const

Returns TRUE if tracking is enabled, or FALSE if tracking is disabled.

Tracking is initially enabled.

See also: setTracking().

voidQSlider::updateMask() [virtualprotected]

Reimplementation of QWidget::updateMask(). Draws the mask of the slider when transparency is required.

See also: QWidget::setAutoMask().

Reimplemented from QWidget.

voidQSlider::valueChange() [virtualprotected]

Implements the virtual QRangeControl function.

Reimplemented from QRangeControl.

voidQSlider::valueChanged(intvalue) [signal]

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

voidQSlider::wheelEvent(QWheelEvent*e) [virtualprotected]

Handles wheel events for the slider.

Reimplemented from QWidget.


Search the documentation, FAQ, qt-interest archive and more (uses www.troll.no):


This file is part of the Qt toolkit, copyright © 1995-99 Troll Tech, all rights reserved.


Copyright 1999 Troll TechTrademarks
Qt version 2.0.2