QAbstractSlider Class
QAbstractSlider 提供一个限制范围的整数. 更多...
头文件: | #include <QAbstractSlider> |
qmake: | QT += widgets |
基类: | QWidget |
派生类: | QDial, QScrollBar, and QSlider |
公有类型
enum | SliderAction { SliderNoAction, SliderSingleStepAdd, SliderSingleStepSub, SliderPageStepAdd, ..., SliderMove } |
属性
|
|
公有函数
QAbstractSlider(QWidget *parent = Q_NULLPTR) | |
~QAbstractSlider() | |
bool | hasTracking() const |
bool | invertedAppearance() const |
bool | invertedControls() const |
bool | isSliderDown() const |
int | maximum() const |
int | minimum() const |
Qt::Orientation | orientation() const |
int | pageStep() const |
void | setInvertedAppearance(bool) |
void | setInvertedControls(bool) |
void | setMaximum(int) |
void | setMinimum(int) |
void | setPageStep(int) |
void | setSingleStep(int) |
void | setSliderDown(bool) |
void | setSliderPosition(int) |
void | setTracking(bool enable) |
int | singleStep() const |
int | sliderPosition() const |
void | triggerAction(SliderAction action) |
int | value() const |
- 214 个公有函数继承自 QWidget
- 32 个公有函数继承自 QObject
- 14 个公有函数继承自 QPaintDevice
公有槽函数
void | setOrientation(Qt::Orientation) |
void | setRange(int min, int max) |
void | setValue(int) |
信号
void | actionTriggered(int action) |
void | rangeChanged(int min, int max) |
void | sliderMoved(int value) |
void | sliderPressed() |
void | sliderReleased() |
void | valueChanged(int value) |
Protected Types
enum | SliderChange { SliderRangeChange, SliderOrientationChange, SliderStepsChange, SliderValueChange } |
受保护的函数
SliderAction | repeatAction() const |
void | setRepeatAction(SliderAction action, int thresholdTime = 500, int repeatTime = 50) |
virtual void | sliderChange(SliderChange change) |
重新实现的受保护函数
virtual void | changeEvent(QEvent *ev) |
virtual bool | event(QEvent *e) |
virtual void | keyPressEvent(QKeyEvent *ev) |
virtual void | timerEvent(QTimerEvent *e) |
virtual void | wheelEvent(QWheelEvent *e) |
- 35 个受保护的函数继承自 QWidget
- 9 个受保护的函数继承自 QObject
- 1 个受保护的函数继承自 QPaintDevice
其他继承的成员
- 1 个公有变量继承自 QObject
- 5 个静态公有成员继承自 QWidget
- 10 个静态公有成员继承自 QObject
- 1 个受保护的槽函数继承自 QWidget
- 2 个受保护的变量继承自 QObject
- 1 protected type inherited from QPaintDevice
详细描述
QAbstractSlider 提供一个限制范围的整数.
这个类是 QScrollBar, QSlider 和 QDial的超类.
这个类的主要属性:
- value: QAbstractSlider 限定范围的值.
- minimum: 最小值.
- maximum: 最大值.
- singleStep: 较小的步长, 对应用户按下方向键.
- pageStep: 较大的步长, 对应用户按下PageUp或PageDown.
- tracking: 是否开启滑块追踪.
- sliderPosition: 滑动条的当前位置. 如果开启 tracking (默认启动), 值等于 value.
value也被视为第三步长. setValue() 函数设置一个[minimum, maximum]范围内的任意整型值, 而不仅仅是 minimum() + n * singleStep()( n 是整型 ). 一些widget允许设置任意值; o而另一些widget只允许设置 singleStep() 或 pageStep()的整数倍.
QAbstractSlider 定义一组全面的信号:
信号 | 发送时机 |
---|---|
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 提供一个虚函数 sliderChange() , 这个函数适合更新滑块显示值. 调用 triggerAction(), 使子类触发滑块动作. 两个助手函数 QStyle::sliderPositionFromValue() 和 QStyle::sliderValueFromPosition() 帮助子类和样式将屏幕坐标映射到逻辑范围值.
参见 QAbstractSpinBox, QSlider, QDial, QScrollBar 及 Sliders Example.
成员类型
enum QAbstractSlider::SliderAction
Constant | Value |
---|---|
QAbstractSlider::SliderNoAction | 0 |
QAbstractSlider::SliderSingleStepAdd | 1 |
QAbstractSlider::SliderSingleStepSub | 2 |
QAbstractSlider::SliderPageStepAdd | 3 |
QAbstractSlider::SliderPageStepSub | 4 |
QAbstractSlider::SliderToMinimum | 5 |
QAbstractSlider::SliderToMaximum | 6 |
QAbstractSlider::SliderMove | 7 |
enum QAbstractSlider::SliderChange
Constant | Value |
---|---|
QAbstractSlider::SliderRangeChange | 0 |
QAbstractSlider::SliderOrientationChange | 1 |
QAbstractSlider::SliderStepsChange | 2 |
QAbstractSlider::SliderValueChange | 3 |
属性
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.
访问函数:
bool | invertedAppearance() const |
void | setInvertedAppearance(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.
访问函数:
bool | invertedControls() const |
void | setInvertedControls(bool) |
maximum : 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.
访问函数:
int | maximum() const |
void | setMaximum(int) |
minimum : 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.
访问函数:
int | minimum() const |
void | setMinimum(int) |
orientation : Qt::Orientation
This property holds the orientation of the slider
The orientation must be Qt::Vertical (the default) or Qt::Horizontal.
访问函数:
Qt::Orientation | orientation() const |
void | setOrientation(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.
访问函数:
int | pageStep() const |
void | setPageStep(int) |
参见 singleStep.
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.
访问函数:
int | singleStep() const |
void | setSingleStep(int) |
参见 pageStep.
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 not tracking has any effect.
Changing the slider down property emits the sliderPressed() and sliderReleased() signals.
访问函数:
bool | isSliderDown() const |
void | setSliderDown(bool) |
sliderPosition : int
This property holds the current slider position
If tracking is enabled (the default), this is identical to value.
访问函数:
int | sliderPosition() const |
void | setSliderPosition(int) |
Notifier signal:
void | sliderMoved(int value) |
tracking : 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.
访问函数:
bool | hasTracking() const |
void | setTracking(bool enable) |
参见 sliderDown.
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 the sliderPosition.
访问函数:
int | value() const |
void | setValue(int) |
Notifier signal:
void | valueChanged(int value) |
成员函数
QAbstractSlider::QAbstractSlider(QWidget *parent = Q_NULLPTR)
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.
QAbstractSlider::~QAbstractSlider()
Destroys the slider.
[signal]
void QAbstractSlider::actionTriggered(int action)
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.
参见 triggerAction().
[virtual protected]
void QAbstractSlider::changeEvent(QEvent *ev)
重新实现 QWidget::changeEvent().
[virtual protected]
bool QAbstractSlider::event(QEvent *e)
重新实现 QObject::event().
[virtual protected]
void QAbstractSlider::keyPressEvent(QKeyEvent *ev)
重新实现 QWidget::keyPressEvent().
[signal]
void QAbstractSlider::rangeChanged(int min, int max)
This signal is emitted when the slider range has changed, with min being the new minimum, and max being the new maximum.
[protected]
SliderAction QAbstractSlider::repeatAction() const
Returns the current repeat action.
参见 setRepeatAction().
[slot]
void QAbstractSlider::setRange(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.
[protected]
void QAbstractSlider::setRepeatAction(SliderAction action, int thresholdTime = 500, int repeatTime = 50)
Sets action action to be triggered repetitively in intervals of repeatTime, after an initial delay of thresholdTime.
参见 triggerAction() and repeatAction().
[virtual protected]
void QAbstractSlider::sliderChange(SliderChange change)
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.
[signal]
void QAbstractSlider::sliderMoved(int value)
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.
Note: Notifier signal for property sliderPosition.
参见 setTracking(), valueChanged(), isSliderDown(), sliderPressed(), and sliderReleased().
[signal]
void QAbstractSlider::sliderPressed()
This signal is emitted when the user presses the slider with the mouse, or programmatically when setSliderDown(true) is called.
参见 sliderReleased(), sliderMoved(), and isSliderDown().
[signal]
void QAbstractSlider::sliderReleased()
This signal is emitted when the user releases the slider with the mouse, or programmatically when setSliderDown(false) is called.
参见 sliderPressed(), sliderMoved(), and sliderDown.
[virtual protected]
void QAbstractSlider::timerEvent(QTimerEvent *e)
重新实现 QObject::timerEvent().
void QAbstractSlider::triggerAction(SliderAction action)
Triggers a slider action. Possible actions are SliderSingleStepAdd, SliderSingleStepSub, SliderPageStepAdd, SliderPageStepSub, SliderToMinimum, SliderToMaximum, and SliderMove.
参见 actionTriggered().
[signal]
void QAbstractSlider::valueChanged(int value)
This signal is emitted when the slider value has changed, with the new slider value as argument.
Note: Notifier signal for property value.
[virtual protected]
void QAbstractSlider::wheelEvent(QWheelEvent *e)
重新实现 QWidget::wheelEvent().