Movatterモバイル変換


[0]ホーム

URL:


We bake cookies in your browser for a better experience. Using this site means that you consent.Read More

Menu

Qt Documentation

QAbstractSlider Class

TheQAbstractSlider class provides an integer value within a range.More...

Header:#include <QAbstractSlider>
Inherits:QWidget
Inherited By:

QDial,QScrollBar, andQSlider

Public Types

enumSliderAction { SliderNoAction, SliderSingleStepAdd, SliderSingleStepSub, SliderPageStepAdd, ..., SliderMove }

Properties

Public Functions

QAbstractSlider(QWidget * parent = 0)
~QAbstractSlider()
boolhasTracking() const
boolinvertedAppearance() const
boolinvertedControls() const
boolisSliderDown() const
intmaximum() const
intminimum() const
Qt::Orientationorientation() const
intpageStep() const
voidsetInvertedAppearance(bool)
voidsetInvertedControls(bool)
voidsetMaximum(int)
voidsetMinimum(int)
voidsetPageStep(int)
voidsetRange(int min, int max)
voidsetSingleStep(int)
voidsetSliderDown(bool)
voidsetSliderPosition(int)
voidsetTracking(bool enable)
intsingleStep() const
intsliderPosition() const
voidtriggerAction(SliderAction action)
intvalue() const

Public Slots

voidsetOrientation(Qt::Orientation)
voidsetValue(int)
  • 19 public slots inherited fromQWidget
  • 1 public slot inherited fromQObject

Signals

voidactionTriggered(int action)
voidrangeChanged(int min, int max)
voidsliderMoved(int value)
voidsliderPressed()
voidsliderReleased()
voidvalueChanged(int value)

Protected Types

enumSliderChange { SliderRangeChange, SliderOrientationChange, SliderStepsChange, SliderValueChange }

Protected Functions

SliderActionrepeatAction() const
voidsetRepeatAction(SliderAction action, int thresholdTime = 500, int repeatTime = 50)
virtual voidsliderChange(SliderChange change)

Reimplemented Protected Functions

virtual voidchangeEvent(QEvent * ev)
virtual boolevent(QEvent * e)
virtual voidkeyPressEvent(QKeyEvent * ev)
virtual voidtimerEvent(QTimerEvent * e)
virtual voidwheelEvent(QWheelEvent * e)
  • 37 protected functions inherited fromQWidget
  • 8 protected functions inherited fromQObject
  • 1 protected function inherited fromQPaintDevice

Additional Inherited Members

  • 4 static public members inherited fromQWidget
  • 7 static public members inherited fromQObject
  • 1 protected slot inherited fromQWidget

Detailed Description

TheQAbstractSlider class provides an integer value within a range.

The class is designed as a common super class for widgets likeQScrollBar,QSlider andQDial.

Here are the main properties of the class:

  1. value: The bounded integer thatQAbstractSlider 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. Iftracking is enabled (the default), this is identical tovalue.

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 justminimum() +n *singleStep() for integer values ofn. Some widgets may allow the user to set any value at all; others may just provide multiples ofsingleStep() orpageStep().

QAbstractSlider emits a comprehensive set of signals:

SignalEmitted when
valueChanged()the value has changed. Thetracking 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 virtualsliderChange() function that is well suited for updating the on-screen representation of sliders. By callingtriggerAction(), subclasses trigger slider actions. Two helper functionsQStyle::sliderPositionFromValue() andQStyle::sliderValueFromPosition() help subclasses and styles to map screen coordinates to logical range values.

See alsoQAbstractSpinBox,QSlider,QDial,QScrollBar, andSliders Example.

Member Type Documentation

enum QAbstractSlider::SliderAction

ConstantValue
QAbstractSlider::SliderNoAction0
QAbstractSlider::SliderSingleStepAdd1
QAbstractSlider::SliderSingleStepSub2
QAbstractSlider::SliderPageStepAdd3
QAbstractSlider::SliderPageStepSub4
QAbstractSlider::SliderToMinimum5
QAbstractSlider::SliderToMaximum6
QAbstractSlider::SliderMove7

enum QAbstractSlider::SliderChange

ConstantValue
QAbstractSlider::SliderRangeChange0
QAbstractSlider::SliderOrientationChange1
QAbstractSlider::SliderStepsChange2
QAbstractSlider::SliderValueChange3

Property Documentation

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

boolinvertedAppearance() const
voidsetInvertedAppearance(bool)

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

boolinvertedControls() const
voidsetInvertedControls(bool)

maximum :int

This property holds the slider's maximum value.

When setting this property, theminimum 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:

intmaximum() const
voidsetMaximum(int)

minimum :int

This property holds the sliders's minimum value.

When setting this property, themaximum 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:

intminimum() const
voidsetMinimum(int)

orientation :Qt::Orientation

This property holds the orientation of the slider.

The orientation must beQt::Vertical (the default) orQt::Horizontal.

Access functions:

Qt::Orientationorientation() const
voidsetOrientation(Qt::Orientation)

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

Access functions:

intpageStep() const
voidsetPageStep(int)

See alsosingleStep.

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

Access functions:

intsingleStep() const
voidsetSingleStep(int)

See alsopageStep.

sliderDown :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 nottracking has any effect.

Changing the slider down property emits thesliderPressed() andsliderReleased() signals.

Access functions:

boolisSliderDown() const
voidsetSliderDown(bool)

sliderPosition :int

This property holds the current slider position.

Iftracking is enabled (the default), this is identical tovalue.

Access functions:

intsliderPosition() const
voidsetSliderPosition(int)

Notifier signal:

voidsliderMoved(int value)

tracking :bool

This property holds whether slider tracking is enabled.

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

Access functions:

boolhasTracking() const
voidsetTracking(bool enable)

See alsosliderDown.

value :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 thesliderPosition.

Access functions:

intvalue() const
voidsetValue(int)

Notifier signal:

voidvalueChanged(int value)

Member Function Documentation

QAbstractSlider::QAbstractSlider(QWidget * parent = 0)

Constructs an abstract slider.

Theparent argument is sent to theQWidget constructor.

Theminimum defaults to 0, themaximum to 99, with asingleStep size of 1 and apageStep size of 10, and an initialvalue of 0.

QAbstractSlider::~QAbstractSlider()

Destroys the slider.

[signal]void QAbstractSlider::actionTriggered(int action)

This signal is emitted when the slider actionaction is triggered. Actions areSliderSingleStepAdd,SliderSingleStepSub,SliderPageStepAdd,SliderPageStepSub,SliderToMinimum,SliderToMaximum, andSliderMove.

When the signal is emitted, thesliderPosition has been adjusted according to the action, but thevalue has not yet been propagated (meaning thevalueChanged() 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 callingsetSliderPosition() yourself, based on both the action and the slider's value.

See alsotriggerAction().

[virtual protected]void QAbstractSlider::changeEvent(QEvent * ev)

Reimplemented fromQWidget::changeEvent().

[virtual protected]bool QAbstractSlider::event(QEvent * e)

Reimplemented fromQObject::event().

[virtual protected]void QAbstractSlider::keyPressEvent(QKeyEvent * ev)

Reimplemented fromQWidget::keyPressEvent().

[signal]void QAbstractSlider::rangeChanged(int min,int max)

This signal is emitted when the slider range has changed, withmin being the new minimum, andmax being the new maximum.

See alsominimum andmaximum.

[protected]SliderAction QAbstractSlider::repeatAction() const

Returns the current repeat action.

See alsosetRepeatAction().

void QAbstractSlider::setRange(int min,int max)

Sets the slider's minimum tomin and its maximum tomax.

Ifmax is smaller thanmin,min becomes the only legal value.

See alsominimum andmaximum.

[protected]void QAbstractSlider::setRepeatAction(SliderAction action,int thresholdTime = 500,int repeatTime = 50)

Sets actionaction to be triggered repetitively in intervals ofrepeatTime, after an initial delay ofthresholdTime.

See alsotriggerAction() andrepeatAction().

[virtual protected]void QAbstractSlider::sliderChange(SliderChange change)

Reimplement this virtual function to track slider changes such asSliderRangeChange,SliderOrientationChange,SliderStepsChange, orSliderValueChange. The default implementation only updates the display and ignores thechange parameter.

[signal]void QAbstractSlider::sliderPressed()

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

See alsosliderReleased(),sliderMoved(), andisSliderDown().

[signal]void QAbstractSlider::sliderReleased()

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

See alsosliderPressed(),sliderMoved(), andsliderDown.

[virtual protected]void QAbstractSlider::timerEvent(QTimerEvent * e)

Reimplemented fromQObject::timerEvent().

void QAbstractSlider::triggerAction(SliderAction action)

Triggers a slideraction. Possible actions areSliderSingleStepAdd,SliderSingleStepSub,SliderPageStepAdd,SliderPageStepSub,SliderToMinimum,SliderToMaximum, andSliderMove.

See alsoactionTriggered().

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

Reimplemented fromQWidget::wheelEvent().

© 2016 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of theGNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.


[8]ページ先頭

©2009-2025 Movatter.jp