QAbstractSlider Class Reference

The QAbstractSlider class provides an integer value within a range.

  1. #include <QAbstractSlider>

Inherits: QWidget.

Inherited by: QDial, QScrollBar, and QSlider.

Detailed Description

The QAbstractSlider class provides an integer value within a range.

The class is designed as a common super class for widgets like QScrollBar, QSlider and QDial.

Here are the main properties of the class:

  1. value: The bounded integer that QAbstractSlider maintains.
  2. minimum: The lowest possible value.
  3. maximum: The highest possible value.
  4. singleStep: The smaller of two natural steps that an abstract sliders provides and typically corresponds to the user pressing an arrow key.
  5. pageStep: The larger of two natural steps that an abstract slider provides and typically corresponds to the user pressing PageUp or PageDown.
  6. tracking: Whether slider tracking is enabled.
  7. sliderPosition: The current position of the slider. If tracking is enabled (the default), this is identical to value.

Unity (1) may be viewed as a third step size. setValue() lets you set the current value to any integer in the allowed range, not just minimum() + n * singleStep() for integer values of n. Some widgets may allow the user to set any value at all; others may just provide multiples of singleStep() or pageStep().

QAbstractSlider emits a comprehensive set of signals:

SignalEmitted when
valueChanged()the value has changed. The tracking determines whether this signal is emitted during user interaction.
sliderPressed()the user starts to drag the slider.
sliderMoved()the user drags the slider.
sliderReleased()the user releases the slider.
actionTriggered()a slider action was triggerd.
rangeChanged()a the range has changed.

QAbstractSlider provides a virtual sliderChange() function that is well suited for updating the on-screen representation of sliders. By calling triggerAction(), subclasses trigger slider actions. Two helper functions QStyle::sliderPositionFromValue() and QStyle::sliderValueFromPosition() help subclasses and styles to map screen coordinates to logical range values.

See also QAbstractSpinBox, QSlider, QDial, QScrollBar, and Sliders Example.

Public Types

Toggle detailsenum QAbstractSlider::

SliderActionSliderAction { SliderNoAction , SliderSingleStepAdd , SliderSingleStepSub , SliderPageStepAdd , SliderPageStepSub , SliderToMinimum , SliderToMaximum , SliderMove 7 ...} { SliderNoAction , SliderSingleStepAdd , SliderSingleStepSub , SliderPageStepAdd , SliderPageStepSub , SliderToMinimum , SliderToMaximum , SliderMove 7 }

ConstantValue
QAbstractSlider::SliderNoAction 0
QAbstractSlider::SliderSingleStepAdd 1
QAbstractSlider::SliderSingleStepSub 2
QAbstractSlider::SliderPageStepAdd 3
QAbstractSlider::SliderPageStepSub 4
QAbstractSlider::SliderToMinimum 5
QAbstractSlider::SliderToMaximum 6
QAbstractSlider::SliderMove 7

Look up this member in the source code.

Toggle detailsenum QAbstractSlider::

SliderChangeSliderChange { SliderRangeChange , SliderOrientationChange , SliderStepsChange , SliderValueChange 3 ...} { SliderRangeChange , SliderOrientationChange , SliderStepsChange , SliderValueChange 3 }

ConstantValue
QAbstractSlider::SliderRangeChange 0
QAbstractSlider::SliderOrientationChange 1
QAbstractSlider::SliderStepsChange 2
QAbstractSlider::SliderValueChange 3

Look up this member in the source code.

    Properties

    Toggle detailsinvertedAppearanceinvertedAppearance : bool

    This property holds whether or not a slider shows its values inverted.

    If this property is false (the default), the minimum and maximum will be shown in its classic position for the inherited widget. If the value is true, the minimum and maximum appear at their opposite location.

    Note: This property makes most sense for sliders and dials. For scroll bars, the visual effect of the scroll bar subcontrols depends on whether or not the styles understand inverted appearance; most styles ignore this property for scroll bars.

    Access functions:

    Look up this member in the source code.

    Toggle detailsinvertedControlsinvertedControls : bool

    This property holds whether or not the slider inverts its wheel and key events.

    If this property is false, scrolling the mouse wheel "up" and using keys like page up will increase the slider's value towards its maximum. Otherwise pressing page up will move value towards the slider's minimum.

    Access functions:

    Look up this member in the source code.

    Toggle detailsmaximummaximum : int

    This property holds the slider's maximum value

    When setting this property, the minimum is adjusted if necessary to ensure that the range remains valid. Also the slider's current value is adjusted to be within the new range.

    Access functions:

    Look up this member in the source code.

    Toggle detailsminimumminimum : int

    This property holds the sliders's minimum value

    When setting this property, the maximum is adjusted if necessary to ensure that the range remains valid. Also the slider's current value is adjusted to be within the new range.

    Access functions:

    Look up this member in the source code.

    Toggle detailsorientationorientation : Qt::Orientation

    This property holds the orientation of the slider

    The orientation must be Qt::Vertical (the default) or Qt::Horizontal.

    Access functions:

    Look up this member in the source code.

    Toggle detailspageSteppageStep : int

    This property holds the page step.

    The larger of two natural steps that an abstract slider provides and typically corresponds to the user pressing PageUp or PageDown.

    See also singleStep.

    Access functions:

    Look up this member in the source code.

    Toggle detailssingleStepsingleStep : int

    This property holds the single step.

    The smaller of two natural steps that an abstract sliders provides and typically corresponds to the user pressing an arrow key.

    If the property is modified during an auto repeating key event, behavior is undefined.

    See also pageStep.

    Access functions:

    Look up this member in the source code.

    Toggle detailssliderDownsliderDown : bool

    This property holds whether the slider is pressed down.

    The property is set by subclasses in order to let the abstract slider know whether or not tracking has any effect.

    Changing the slider down property emits the sliderPressed() and sliderReleased() signals.

    Access functions:

    Look up this member in the source code.

    Toggle detailssliderPositionsliderPosition : int

    This property holds the current slider position

    If tracking is enabled (the default), this is identical to value.

    Access functions:

    Look up this member in the source code.

    Toggle detailstrackingtracking : bool

    This property holds whether slider tracking is enabled

    If tracking is enabled (the default), the slider emits the valueChanged() signal while the slider is being dragged. If tracking is disabled, the slider emits the valueChanged() signal only when the user releases the slider.

    See also sliderDown.

    Access functions:

    Look up this member in the source code.

    Toggle detailsvaluevalue : int

    This property holds the slider's current value

    The slider forces the value to be within the legal range: minimum <= value <= maximum.

    Changing the value also changes the sliderPosition.

    Access functions:

    Look up this member in the source code.

      Public Functions

      Toggle details QAbstractSlider

      QAbstractSliderQAbstractSlider ( QWidget *parent=0 ) ( QWidget *parent=0 )

      Constructs an abstract slider.

      The parent argument is sent to the QWidget constructor.

      The minimum defaults to 0, the maximum to 99, with a singleStep size of 1 and a pageStep size of 10, and an initial value of 0.

      Look up this member in the source code.

      Toggle details QAbstractSlider

      ~QAbstractSlider~QAbstractSlider () ()

      Destroys the slider.

      Look up this member in the source code.

      Toggle details void QAbstractSlider

      changeEventchangeEvent ( QEvent *ev ) ( QEvent *ev ) [virtual protected]

      Reimplemented from QWidget::changeEvent().

      Look up this member in the source code.

      Toggle details bool QAbstractSlider

      eventevent ( QEvent *e ) ( QEvent *e ) [virtual protected]

      Reimplemented from QObject::event().

      Look up this member in the source code.

      Toggle details void QAbstractSlider

      keyPressEventkeyPressEvent ( QKeyEvent *ev ) ( QKeyEvent *ev ) [virtual protected]

      Reimplemented from QWidget::keyPressEvent().

      Look up this member in the source code.

      Toggle details SliderAction QAbstractSlider

      repeatActionrepeatAction () ()const[protected]

      Returns the current repeat action.

      See also setRepeatAction().

      Look up this member in the source code.

      Toggle details void QAbstractSlider

      setRangesetRange ( int min , int max ) ( int min , int max )

      Sets the slider's minimum to min and its maximum to max.

      If max is smaller than min, min becomes the only legal value.

      See also minimum and maximum.

      Look up this member in the source code.

      Toggle details void QAbstractSlider

      setRepeatActionsetRepeatAction ( SliderAction action , int thresholdTime=500 , int repeatTime=50 ...) ( SliderAction action , int thresholdTime=500 , int repeatTime=50 )[protected]

      Sets action action to be triggered repetitively in intervals of repeatTime, after an initial delay of thresholdTime.

      See also triggerAction() and repeatAction().

      Look up this member in the source code.

      Toggle details void QAbstractSlider

      sliderChangesliderChange ( SliderChange change ) ( SliderChange change ) [virtual protected]

      Reimplement this virtual function to track slider changes such as SliderRangeChange, SliderOrientationChange, SliderStepsChange, or SliderValueChange. The default implementation only updates the display and ignores the change parameter.

      Look up this member in the source code.

      Toggle details void QAbstractSlider

      timerEventtimerEvent ( QTimerEvent *e ) ( QTimerEvent *e ) [virtual protected]

      Reimplemented from QObject::timerEvent().

      Look up this member in the source code.

      Toggle details void QAbstractSlider

      triggerActiontriggerAction ( SliderAction action ) ( SliderAction action )

      Look up this member in the source code.

      Toggle details void QAbstractSlider

      wheelEventwheelEvent ( QWheelEvent *e ) ( QWheelEvent *e ) [virtual protected]

      Reimplemented from QWidget::wheelEvent().

      Look up this member in the source code.

      Toggle details void QAbstractSlider

      addLineaddLine () () Qt3-support

      Use triggerAction(QAbstractSlider::SliderSingleStepAdd) instead.

      Look up this member in the source code.

      Toggle details void QAbstractSlider

      addPageaddPage () () Qt3-support

      Use triggerAction(QAbstractSlider::SliderPageStepAdd) instead.

      Look up this member in the source code.

      Toggle details int QAbstractSlider

      lineSteplineStep () ()const Qt3-support

      Use singleStep() instead.

      See also setLineStep().

      Look up this member in the source code.

      Toggle details int QAbstractSlider

      maxValuemaxValue () ()const Qt3-support

      Use maximum() instead.

      See also setMaxValue().

      Look up this member in the source code.

      Toggle details int QAbstractSlider

      minValueminValue () ()const Qt3-support

      Use minimum() instead.

      See also setMinValue().

      Look up this member in the source code.

      Toggle details void QAbstractSlider

      setLineStepsetLineStep ( int v ) ( int v ) Qt3-support

      Use setSingleStep() instead.

      See also lineStep().

      Look up this member in the source code.

      Toggle details void QAbstractSlider

      setMaxValuesetMaxValue ( int v ) ( int v ) Qt3-support

      Use setMaximum() instead.

      See also maxValue().

      Look up this member in the source code.

      Toggle details void QAbstractSlider

      setMinValuesetMinValue ( int v ) ( int v ) Qt3-support

      Use setMinimum() instead.

      See also minValue().

      Look up this member in the source code.

      Toggle details void QAbstractSlider

      setStepssetSteps ( int single , int page ) ( int single , int page ) Qt3-support

      Use setSingleStep(single) followed by setPageStep(page) instead.

      Look up this member in the source code.

      Toggle details void QAbstractSlider

      subtractLinesubtractLine () () Qt3-support

      Use triggerAction(QAbstractSlider::SliderSingleStepSub) instead.

      Look up this member in the source code.

      Toggle details void QAbstractSlider

      subtractPagesubtractPage () () Qt3-support

      Use triggerAction(QAbstractSlider::SliderPageStepSub) instead.

      Look up this member in the source code.

      Signals

      Toggle details void QAbstractSlider

      actionTriggeredactionTriggered ( int action ) ( int action ) [signal]

      This signal is emitted when the slider action action is triggered. Actions are SliderSingleStepAdd, SliderSingleStepSub, SliderPageStepAdd, SliderPageStepSub, SliderToMinimum, SliderToMaximum, and SliderMove.

      When the signal is emitted, the sliderPosition has been adjusted according to the action, but the value has not yet been propagated (meaning the valueChanged() signal was not yet emitted), and the visual display has not been updated. In slots connected to this signal you can thus safely adjust any action by calling setSliderPosition() yourself, based on both the action and the slider's value.

      See also triggerAction().

      Look up this member in the source code.

      Toggle details void QAbstractSlider

      rangeChangedrangeChanged ( int min , int max ) ( int min , int max ) [signal]

      This signal is emitted when the slider range has changed, with min being the new minimum, and max being the new maximum.

      See also minimum and maximum.

      Look up this member in the source code.

      Toggle details void QAbstractSlider

      sliderMovedsliderMoved ( int value ) ( int value ) [signal]

      This signal is emitted when sliderDown is true and the slider moves. This usually happens when the user is dragging the slider. The value is the new slider position.

      This signal is emitted even when tracking is turned off.

      See also setTracking(), valueChanged(), isSliderDown(), sliderPressed(), and sliderReleased().

      Look up this member in the source code.

      Toggle details void QAbstractSlider

      sliderPressedsliderPressed () () [signal]

      This signal is emitted when the user presses the slider with the mouse, or programmatically when setSliderDown(true) is called.

      See also sliderReleased(), sliderMoved(), and isSliderDown().

      Look up this member in the source code.

      Toggle details void QAbstractSlider

      sliderReleasedsliderReleased () () [signal]

      This signal is emitted when the user releases the slider with the mouse, or programmatically when setSliderDown(false) is called.

      See also sliderPressed(), sliderMoved(), and sliderDown.

      Look up this member in the source code.

      Toggle details void QAbstractSlider

      valueChangedvalueChanged ( int value ) ( int value ) [signal]

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

      Look up this member in the source code.

      Notes provided by the Qt Community

      No notes