Classes - Annotated - Tree - Functions - Home - Structure

QSlider Class Reference

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

#include <qslider.h>

Inherits QWidget and QRangeControl.

List of all member functions.

Public Members

Public Slots

Signals

Properties

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 be horizontal or vertical.

A slider has a default focusPolicy() of WeakWheelFocus, i.e., it accepts focus on Tab and uses the mouse wheel and a suitable keyboard interface.

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


Member Type Documentation

QSlider::TickSetting

This enum specifies where the tickmarks 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 ( QWidget * parent, const char * name = 0 )

Constructs a vertical slider.

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

QSlider::QSlider ( Orientation orientation, QWidget * parent, const char * 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 ( int minValue, int maxValue, int pageStep, int value, Orientation orientation, QWidget * parent, const char * name = 0 )

Constructs a slider whose value can never be smaller than minValue or greater than maxValue, whose page step size is pageStep and whose value is initially value (adjusted using bound()).

If orientation is Vertical the slider is vertical and if it is Horizontal the slider is horizontal.

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

void QSlider::addStep () [slot]

Moves the slider one pageStep() upward.

void QSlider::drawTicks ( QPainter * p, const QColorGroup & g, int dist, int w, int i = 1 ) const [protected]

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

Setting the color group is useful for reusing the code to draw a mask if the slider supports transparency.

void QSlider::drawTicks ( QPainter * p, int dist, int w, int i = 1 ) const [protected]

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

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Do not reimplement this function; it exists purely for compatibility reasons. It calls the main version, and we recommend reimplementing that, when required.

void QSlider::drawWinGroove ( QPainter * p, QCOORD c ) [protected]

This function is obsolete. It is provided to keep old source 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.

int QSlider::lineStep () const

Returns the current line step. See the "lineStep" property for details.

int QSlider::maxValue () const

Returns the current maximum value of the slider. See the "maxValue" property for details.

int QSlider::minValue () const

Returns the current minimum value of the slider. See the "minValue" property for details.

Orientation QSlider::orientation () const

Returns the orientation of the slider. See the "orientation" property for details.

int QSlider::pageStep () const

Returns the current line step. See the "pageStep" property for details.

void QSlider::paintSlider ( QPainter * p, const QColorGroup & g, const QRect & r ) [virtual protected]

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

Setting the color group is useful for reusing the code to draw a mask if the slider supports transparency.

void QSlider::rangeChange () [virtual protected]

Implements the virtual QRangeControl function.

Reimplemented from QRangeControl.

void QSlider::setLineStep ( int )

Sets the current line step. See the "lineStep" property for details.

void QSlider::setMaxValue ( int )

Sets the current maximum value of the slider. See the "maxValue" property for details.

void QSlider::setMinValue ( int )

Sets the current minimum value of the slider. See the "minValue" property for details.

void QSlider::setOrientation ( Orientation ) [virtual]

Sets the orientation of the slider. See the "orientation" property for details.

void QSlider::setPageStep ( int )

Sets the current line step. See the "pageStep" property for details.

void QSlider::setPalette ( const QPalette & p ) [virtual]

Reimplements the virtual function QWidget::setPalette().

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

Reimplemented from QWidget.

void QSlider::setTickInterval ( int ) [virtual]

Sets the interval between tickmarks. See the "tickInterval" property for details.

void QSlider::setTickmarks ( TickSetting ) [virtual]

Sets the tickmark settings for this slider. See the "tickmarks" property for details.

void QSlider::setTracking ( bool enable ) [virtual]

Sets whether slider tracking is enabled to enable. See the "tracking" property for details.

void QSlider::setValue ( int ) [virtual slot]

Sets the current slider value. See the "value" property for details.

void QSlider::sliderMoved ( int value ) [signal]

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

void QSlider::sliderPressed () [signal]

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

QRect QSlider::sliderRect () const

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

void QSlider::sliderReleased () [signal]

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

void QSlider::subtractStep () [slot]

Moves the slider one pageStep() downwards.

int QSlider::thickness () const [virtual protected]

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.

int QSlider::tickInterval () const

Returns the interval between tickmarks. See the "tickInterval" property for details.

TickSetting QSlider::tickmarks () const

Returns the tickmark settings for this slider. See the "tickmarks" property for details.

bool QSlider::tracking () const

Returns TRUE if slider tracking is enabled; otherwise returns FALSE. See the "tracking" property for details.

int QSlider::value () const

Returns the current slider value. See the "value" property for details.

void QSlider::valueChange () [virtual protected]

Implements the virtual QRangeControl function.

Reimplemented from QRangeControl.

void QSlider::valueChanged ( int value ) [signal]

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

Examples: t10/lcdrange.cpp, t11/lcdrange.cpp, t12/lcdrange.cpp, t7/lcdrange.cpp, t8/lcdrange.cpp and t9/lcdrange.cpp.


Property Documentation

int lineStep

This property holds the current line step.

When setting lineStep, the virtual stepChange() function will be called if the new line step is different from the previous setting.

Set this property's value with setLineStep() and get this property's value with lineStep().

See also setSteps(), QRangeControl::pageStep() and setRange().

int maxValue

This property holds the current maximum value of the slider.

When setting this property, the minValue is adjusted so that the range remains valid if necessary.

Set this property's value with setMaxValue() and get this property's value with maxValue().

See also setRange().

int minValue

This property holds the current minimum value of the slider.

When setting this property, the maxValue is adjusted so that the range remains valid if necessary.

Set this property's value with setMinValue() and get this property's value with minValue().

See also setRange().

Orientation orientation

This property holds the orientation of the slider.

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

Set this property's value with setOrientation() and get this property's value with orientation().

int pageStep

This property holds the current line step.

When setting pageStep, the virtual stepChange() function will be called if the new page step is different from the previous setting.

Set this property's value with setPageStep() and get this property's value with pageStep().

See also QRangeControl::setSteps(), lineStep and setRange().

int tickInterval

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.

Set this property's value with setTickInterval() and get this property's value with tickInterval().

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

TickSetting tickmarks

This property holds the tickmark settings for this slider.

This property can have the following values:

The initial value is NoMarks.

See also tickInterval.

Set this property's value with setTickmarks() and get this property's value with tickmarks().

bool tracking

This property holds whether slider tracking is enabled.

If tracking is enabled (the 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).

Set this property's value with setTracking() and get this property's value with tracking().

int value

This property holds the current slider value.

Set this property's value with setValue() and get this property's value with value().

See also QRangeControl::value() and prevValue().


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


This file is part of the Qt toolkit, copyright © 1995-2001 Trolltech, all rights reserved.


Copyright © 2001 TrolltechTrademarks
Qt version 3.0.0-beta1-beta1