Viadeo Twitter Google Bookmarks ! Facebook Digg del.icio.us MySpace Yahoo MyWeb Blinklist Netvouz Reddit Simpy StumbleUpon Bookmarks Windows Live Favorites 
Logo Documentation Qt ·  Page d'accueil  ·  Classes  ·  Annotées  ·  Hiérarchie  ·  Fonctions  ·  Structure  · 

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

  • enum TickSetting { NoMarks = 0, Above = 1, Left = Above, Below = 2, Right = Below, Both = 3 }
  • QSlider ( QWidget * parent, const char * name=0 ) 
  • QSlider ( Orientation, QWidget * parent, const char * name=0 ) 
  • QSlider ( int minValue, int maxValue, int pageStep, int value, Orientation, QWidget * parent, const char * name=0 ) 
  • virtual void setOrientation ( Orientation ) 
  • Orientation orientation () const
  • virtual void setTracking ( bool enable ) 
  • bool tracking () const
  • virtual void setPalette ( const QPalette & ) 
  • QRect sliderRect () const
  • virtual void setTickmarks ( TickSetting ) 
  • TickSetting tickmarks () const
  • virtual void setTickInterval ( int ) 
  • int tickInterval () const
  • void setMinValue ( int ) 
  • void setMaxValue ( int ) 
  • void setLineStep ( int ) 
  • void setPageStep ( int ) 

Public Slots

Signals

Protected Members

  • virtual void updateMask () 
  • virtual void valueChange () 
  • virtual void rangeChange () 
  • virtual void paintSlider ( QPainter *, const QColorGroup &, const QRect & ) 
  • void drawTicks ( QPainter *, const QColorGroup &, int, int, int=1 ) const
  • void drawWinGroove ( QPainter *, QCOORD ) (obsolete)
  • void drawTicks ( QPainter *, int, int, int=1 ) const (obsolete)
  • virtual int thickness () const

Properties

TypeNameREADWRITEOptions
intminValueminValuesetMinValue 
intmaxValuemaxValuesetMaxValue 
intlineSteplineStepsetLineStep 
intpageSteppageStepsetPageStep 
intvaluevaluesetValue 
booltrackingtrackingsetTracking 
OrientationorientationorientationsetOrientation 
TickSettingtickmarkstickmarkssetTickmarks 
inttickIntervaltickIntervalsetTickInterval 

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 WeakWheelFocus, i.e. it accepts focus on Tab and by using the mouse wheel, 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 ( 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 ( QWidget * parent, const char * name=0 )

Constructs a vertical slider.

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.

Arguments:

  • minValue is the minimum slider value.
  • maxValue is the maximum slider value.
  • step is the page step value.
  • value is the initial value.
  • orientation must be QSlider::Vertical or QSlider::Horizontal.
The parent and name arguments are sent to the QWidget constructor.

void QSlider::addStep () [slot]

Moves the slider one pageStep() upwards.

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 colorgroup is useful to reuse the code to draw a mask if the slider supports transparceny.

See also setAutoMask() and updateMask().

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, and will probably be removed in a future version of Qt. We strongly advise against using it in new code.

\overload

Do not reimplement this function, it's only there for compatibility reasons. It simply calls the other version with colorGroup() as the second argument.

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

This function is obsolete. It is provided to keep old source working, and will probably be removed in a future version of Qt. 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.

void QSlider::focusInEvent ( QFocusEvent * e ) [virtual protected]

Reimplemented for internal reasons; the API is not affected.

Reimplemented from QWidget.

void QSlider::focusOutEvent ( QFocusEvent * e ) [virtual protected]

Reimplemented for internal reasons; the API is not affected.

Reimplemented from QWidget.

void QSlider::keyPressEvent ( QKeyEvent * e ) [virtual protected]

Reimplemented for internal reasons; the API is not affected.

Reimplemented from QWidget.

int QSlider::lineStep () const

Reimplemented for internal reasons; the API is not affected.

int QSlider::maxValue () const

Reimplemented for internal reasons; the API is not affected.

int QSlider::minValue () const

Reimplemented for internal reasons; the API is not affected.

QSize QSlider::minimumSizeHint () const [virtual]

Reimplemented for internal reasons; the API is not affected.

Reimplemented from QWidget.

void QSlider::mouseMoveEvent ( QMouseEvent * e ) [virtual protected]

Reimplemented for internal reasons; the API is not affected.

Reimplemented from QWidget.

void QSlider::mousePressEvent ( QMouseEvent * e ) [virtual protected]

Reimplemented for internal reasons; the API is not affected.

Reimplemented from QWidget.

void QSlider::mouseReleaseEvent ( QMouseEvent * ) [virtual protected]

Reimplemented for internal reasons; the API is not affected.

Reimplemented from QWidget.

Orientation QSlider::orientation () const

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

See also setOrientation().

int QSlider::pageStep () const

Reimplemented for internal reasons; the API is not affected.

void QSlider::paintEvent ( QPaintEvent * ) [virtual protected]

Reimplemented for internal reasons; the API is not affected.

Reimplemented from QWidget.

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

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().

void QSlider::rangeChange () [virtual protected]

Implements the virtual QRangeControl function.

Reimplemented from QRangeControl.

void QSlider::resizeEvent ( QResizeEvent * ) [virtual protected]

Reimplemented for internal reasons; the API is not affected.

Reimplemented from QWidget.

void QSlider::setLineStep ( int i )

Sets the line step to i.

Calls the virtual stepChange() function if the new line step is different from the previous setting.

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

void QSlider::setMaxValue ( int i )

A convenience function which just calls setRange( minValue(), i )

See also setRange().

void QSlider::setMinValue ( int i )

A convenience function which just calls setRange( i, maxValue() )

See also setRange().

void QSlider::setOrientation ( Orientation orientation ) [virtual]

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

See also orientation().

void QSlider::setPageStep ( int i )

Sets the page step to i.

Calls the virtual stepChange() function if the new page step is different from the previous setting.

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

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.

void QSlider::setTickInterval ( int i ) [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().

void QSlider::setTickmarks ( TickSetting s )

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

  • NoMarks
  • Above
  • Left
  • Below
  • Right
  • Both
The initial value is NoMarks.

See also tickmarks() and setTickInterval().

void QSlider::setTracking ( bool enable ) [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().

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

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

Examples: xform/xform.cpp

QSize QSlider::sizeHint () const [virtual]

Reimplemented for internal reasons; the API is not affected.

Reimplemented from QWidget.

QSizePolicy QSlider::sizePolicy () const [virtual]

Reimplemented for internal reasons; the API is not affected.

Reimplemented from QWidget.

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::styleChange ( QStyle & old ) [virtual protected]

Reimplemented for internal reasons; the API is not affected.

Reimplemented from QWidget.

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. Returns 0 if the slider chooses between pageStep() and lineStep().

See also setTickInterval().

QSlider::TickSetting QSlider::tickmarks() const

Returns the tickmark settings for this slider.

See also setTickmarks().

bool QSlider::tracking () const

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

Tracking is initially enabled.

See also setTracking().

void QSlider::updateMask () [virtual protected]

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

See also QWidget::setAutoMask().

Reimplemented from QWidget.

int QSlider::value () const

Reimplemented for internal reasons; the API is not affected.

Examples: xform/xform.cpp

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.

void QSlider::wheelEvent ( QWheelEvent * e ) [virtual protected]

Reimplemented for internal reasons; the API is not affected.

Reimplemented from QWidget.


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


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

Publicité

Best Of

Actualités les plus lues

Semaine
Mois
Année
  1. « Quelque chose ne va vraiment pas avec les développeurs "modernes" », un développeur à "l'ancienne" critique la multiplication des bibliothèques 68
  2. Apercevoir la troisième dimension ou l'utilisation multithreadée d'OpenGL dans Qt, un article des Qt Quarterly traduit par Guillaume Belz 0
  3. Les développeurs ignorent-ils trop les failles découvertes dans leur code ? Prenez-vous en compte les remarques des autres ? 17
  4. BlackBerry 10 : premières images du prochain OS de RIM qui devrait intégrer des widgets et des tuiles inspirées de Windows Phone 0
  5. Quelles nouveautés de C++11 Visual C++ doit-il rapidement intégrer ? Donnez-nous votre avis 10
  6. Adieu qmake, bienvenue qbs : Qt Building Suite, un outil déclaratif et extensible pour la compilation de projets Qt 17
  7. La rubrique Qt a besoin de vous ! 1
Page suivante

Le Qt Labs au hasard

Logo

Peek et Poke

Les Qt Labs sont les laboratoires des développeurs de Qt, où ils peuvent partager des impressions sur le framework, son utilisation, ce que pourrait être son futur. Lire l'article.

Communauté

Ressources

Liens utiles

Contact

  • Vous souhaitez rejoindre la rédaction ou proposer un tutoriel, une traduction, une question... ? Postez dans le forum Contribuez ou contactez-nous par MP ou par email (voir en bas de page).

Qt dans le magazine

Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. Qt 2.3
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD.
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP !
 
 
 
 
Partenaires

Hébergement Web