Eneboo - Documentación para desarrolladores
|
The QSlider widget provides a vertical or horizontal slider. Más...
#include <qslider.h>
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 within 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 accepts focus on Tab and uses the mouse wheel and a suitable keyboard interface.
setRange
enum QSlider::TickSetting |
This enum specifies where the tickmarks are to be drawn relative to the slider's groove and the handle the user moves.
NoMarks do not draw any tickmarks. Both draw tickmarks on both sides of the groove. Above draw tickmarks above the (horizontal) slider Below draw tickmarks below the (horizontal) slider Left draw tickmarks to the left of the (vertical) slider Right draw tickmarks to the right of the (vertical) slider
enum QSlider::TickSetting |
QSlider::QSlider | ( | QWidget * | parent, |
const char * | name = 0 |
||
) |
Constructs a vertical slider.
The parent and name arguments are sent on to the QWidget constructor.
QSlider::QSlider | ( | Orientation | orientation, |
QWidget * | parent, | ||
const char * | name = 0 |
||
) |
Constructs a slider.
The orientation must be Qt::Vertical or Qt::Horizontal.
The parent and name arguments are sent on 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 (which is guaranteed to be in range using bound()).
If orientation is Qt::Vertical
the slider is vertical and if it is Qt::Horizontal
the slider is horizontal.
The parent and name arguments are sent on to the QWidget constructor.
QSlider::~QSlider | ( | ) |
Destructor.
QSlider::QSlider | ( | QWidget * | parent, |
const char * | name = 0 |
||
) |
QSlider::QSlider | ( | Orientation | , |
QWidget * | parent, | ||
const char * | name = 0 |
||
) |
QSlider::QSlider | ( | int | minValue, |
int | maxValue, | ||
int | pageStep, | ||
int | value, | ||
Orientation | , | ||
QWidget * | parent, | ||
const char * | name = 0 |
||
) |
QSlider::~QSlider | ( | ) |
void QSlider::addLine | ( | ) | [slot] |
Reimplementado de QRangeControl.
void QSlider::addLine | ( | ) | [slot] |
Equivalent to {setValue( value() + lineStep() )}.
If the value is changed, then valueChange() is called.
Reimplementado de QRangeControl.
void QSlider::addStep | ( | ) | [slot] |
void QSlider::addStep | ( | ) | [slot] |
Moves the slider one pageStep() up or right.
void QSlider::focusInEvent | ( | QFocusEvent * | e | ) | [protected, virtual] |
Reimplementado de QWidget.
void QSlider::focusInEvent | ( | QFocusEvent * | ) | [protected, virtual] |
This event handler can be reimplemented in a subclass to receive keyboard focus events (focus received) for the widget.
A widget normally must setFocusPolicy() to something other than NoFocus
in order to receive focus events. (Note that the application programmer can call setFocus() on any widget, even those that do not normally accept focus.)
The default implementation updates the widget (except for toplevel widgets that do not specify a focusPolicy() ). It also calls setMicroFocusHint(), hinting any system-specific input tools about the focus of the user's attention.
Reimplementado de QWidget.
void QSlider::focusOutEvent | ( | QFocusEvent * | e | ) | [protected, virtual] |
Reimplementado de QWidget.
void QSlider::focusOutEvent | ( | QFocusEvent * | ) | [protected, virtual] |
This event handler can be reimplemented in a subclass to receive keyboard focus events (focus lost) for the widget.
A widget normally must setFocusPolicy() to something other than NoFocus
in order to receive focus events. (Note that the application programmer can call setFocus() on any widget, even those that do not normally accept focus.)
The default implementation updates the widget (except for toplevel widgets that do not specify a focusPolicy() ). It also calls setMicroFocusHint(), hinting any system-specific input tools about the focus of the user's attention.
Reimplementado de QWidget.
void QSlider::keyPressEvent | ( | QKeyEvent * | e | ) | [protected, virtual] |
This event handler, for event e, can be reimplemented in a subclass to receive key press events for the widget.
A widget must call setFocusPolicy() to accept focus initially and have focus in order to receive a key press event.
If you reimplement this handler, it is very important that you explicitly ignore the event if you do not understand it, so that the widget's parent can interpret it; otherwise, the event will be implicitly accepted. Although top-level widgets are able to choose whether to accept or ignore unknown events because they have no parent widgets that could otherwise handle them, it is good practice to explicitly ignore events to make widgets as reusable as possible.
The default implementation closes popup widgets if the user presses Esc. Otherwise the event is ignored.
Reimplementado de QWidget.
int QSlider::lineStep | ( | ) | const |
int QSlider::lineStep | ( | ) | const |
int QSlider::maxValue | ( | ) | const |
Returns the maximum value of the range.
Reimplementado de QRangeControl.
int QSlider::maxValue | ( | ) | const |
Returns the maximum value of the range.
Reimplementado de QRangeControl.
int QSlider::minValue | ( | ) | const |
Returns the minimum value of the range.
Reimplementado de QRangeControl.
int QSlider::minValue | ( | ) | const |
Returns the minimum value of the range.
Reimplementado de QRangeControl.
void QSlider::mouseMoveEvent | ( | QMouseEvent * | e | ) | [protected, virtual] |
This event handler, for event e, can be reimplemented in a subclass to receive mouse move events for the widget.
If mouse tracking is switched off, mouse move events only occur if a mouse button is pressed while the mouse is being moved. If mouse tracking is switched on, mouse move events occur even if no mouse button is pressed.
QMouseEvent::pos() reports the position of the mouse cursor, relative to this widget. For press and release events, the position is usually the same as the position of the last mouse move event, but it might be different if the user's hand shakes. This is a feature of the underlying window system, not Qt.
Reimplementado de QWidget.
void QSlider::mouseMoveEvent | ( | QMouseEvent * | e | ) | [protected, virtual] |
Reimplementado de QWidget.
void QSlider::mousePressEvent | ( | QMouseEvent * | e | ) | [protected, virtual] |
Reimplementado de QWidget.
void QSlider::mousePressEvent | ( | QMouseEvent * | e | ) | [protected, virtual] |
This event handler, for event e, can be reimplemented in a subclass to receive mouse press events for the widget.
If you create new widgets in the mousePressEvent() the mouseReleaseEvent() may not end up where you expect, depending on the underlying window system (or X11 window manager), the widgets' location and maybe more.
The default implementation implements the closing of popup widgets when you click outside the window. For other widget types it does nothing.
Reimplementado de QWidget.
void QSlider::mouseReleaseEvent | ( | QMouseEvent * | ) | [protected, virtual] |
Reimplementado de QWidget.
void QSlider::mouseReleaseEvent | ( | QMouseEvent * | e | ) | [protected, virtual] |
This event handler, for event e, can be reimplemented in a subclass to receive mouse release events for the widget.
Reimplementado de QWidget.
Orientation QSlider::orientation | ( | ) | const |
Orientation QSlider::orientation | ( | ) | const |
int QSlider::pageStep | ( | ) | const |
int QSlider::pageStep | ( | ) | const |
void QSlider::paintEvent | ( | QPaintEvent * | ) | [protected, virtual] |
Reimplementado de QWidget.
void QSlider::paintEvent | ( | QPaintEvent * | ) | [protected, virtual] |
This event handler can be reimplemented in a subclass to receive paint events.
A paint event is a request to repaint all or part of the widget. It can happen as a result of repaint() or update(), or because the widget was obscured and has now been uncovered, or for many other reasons.
Many widgets can simply repaint their entire surface when asked to, but some slow widgets need to optimize by painting only the requested region: QPaintEvent::region(). This speed optimization does not change the result, as painting is clipped to that region during event processing. QListView and QCanvas do this, for example.
Qt also tries to speed up painting by merging multiple paint events into one. When update() is called several times or the window system sends several paint events, Qt merges these events into one event with a larger region (see QRegion::unite()). repaint() does not permit this optimization, so we suggest using update() when possible.
When the paint event occurs, the update region has normally been erased, so that you're painting on the widget's background. There are a couple of exceptions and QPaintEvent::erased() tells you whether the widget has been erased or not.
The background can be set using setBackgroundMode(), setPaletteBackgroundColor() or setBackgroundPixmap(). The documentation for setBackgroundMode() elaborates on the background; we recommend reading it.
Reimplementado de QWidget.
void QSlider::rangeChange | ( | ) | [protected, virtual] |
Implements the virtual QRangeControl function.
Reimplementado de QRangeControl.
void QSlider::rangeChange | ( | ) | [protected, virtual] |
This virtual function is called whenever the range control's range changes. You can reimplement it if you want to be notified when the range changes. The default implementation does nothing.
Note that this method is called after the range has changed.
Reimplementado de QRangeControl.
void QSlider::resizeEvent | ( | QResizeEvent * | ) | [protected, virtual] |
Reimplementado de QWidget.
void QSlider::resizeEvent | ( | QResizeEvent * | ) | [protected, virtual] |
This event handler can be reimplemented in a subclass to receive widget resize events. When resizeEvent() is called, the widget already has its new geometry. The old size is accessible through QResizeEvent::oldSize().
The widget will be erased and receive a paint event immediately after processing the resize event. No drawing need be (or should be) done inside this handler.
Widgets that have been created with the WNoAutoErase
flag will not be erased. Nevertheless, they will receive a paint event for their entire area afterwards. Again, no drawing needs to be done inside this handler.
The default implementation calls updateMask() if the widget has automatic masking enabled.
Reimplementado de QWidget.
void QSlider::setLineStep | ( | int | ) |
void QSlider::setLineStep | ( | int | i | ) |
void QSlider::setMaxValue | ( | int | maxVal | ) |
Sets the minimum value of the range to maxVal.
If necessary, the minValue() is adjusted so that the range remains valid.
Reimplementado de QRangeControl.
void QSlider::setMaxValue | ( | int | maxVal | ) |
Sets the minimum value of the range to maxVal.
If necessary, the minValue() is adjusted so that the range remains valid.
Reimplementado de QRangeControl.
void QSlider::setMinValue | ( | int | minVal | ) |
Sets the minimum value of the range to minVal.
If necessary, the maxValue() is adjusted so that the range remains valid.
Reimplementado de QRangeControl.
void QSlider::setMinValue | ( | int | minVal | ) |
Sets the minimum value of the range to minVal.
If necessary, the maxValue() is adjusted so that the range remains valid.
Reimplementado de QRangeControl.
void QSlider::setOrientation | ( | Orientation | orientation | ) | [virtual] |
virtual void QSlider::setOrientation | ( | Orientation | ) | [virtual] |
void QSlider::setPageStep | ( | int | ) |
void QSlider::setPageStep | ( | int | i | ) |
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 using palette p.
Reimplementado de QWidget.
void QSlider::setSizePolicy | ( | QSizePolicy | sp | ) | [virtual] |
Reimplementado de QWidget.
void QSlider::setSizePolicy | ( | QSizePolicy::SizeType | hor, |
QSizePolicy::SizeType | ver, | ||
bool | hfw = FALSE |
||
) | [inline] |
Reimplementado de QWidget.
void QSlider::setSizePolicy | ( | QSizePolicy | sp | ) | [virtual] |
Reimplementado de QWidget.
void QSlider::setSizePolicy | ( | QSizePolicy::SizeType | hor, |
QSizePolicy::SizeType | ver, | ||
bool | hfw = FALSE |
||
) |
Esta es una función miembro sobrecargada que se suministra por conveniencia. Difiere de la anterior función solamente en los argumentos que acepta.
Sets the size policy of the widget to hor, ver and hfw (height for width).
Reimplementado de QWidget.
void QSlider::setTickInterval | ( | int | i | ) | [virtual] |
virtual void QSlider::setTickInterval | ( | int | ) | [virtual] |
void QSlider::setTickmarks | ( | TickSetting | s | ) | [virtual] |
virtual void QSlider::setTickmarks | ( | TickSetting | ) | [virtual] |
virtual void QSlider::setTracking | ( | bool | enable | ) | [virtual] |
void QSlider::setTracking | ( | bool | enable | ) | [virtual] |
virtual void QSlider::setValue | ( | int | value | ) | [virtual, slot] |
Sets the range control's value to value and forces it to be within the legal range.
Calls the virtual valueChange() function if the new value is different from the previous value. The old value can still be retrieved using prevValue().
Reimplementado de QRangeControl.
void QSlider::setValue | ( | int | value | ) | [virtual, slot] |
Sets the range control's value to value and forces it to be within the legal range.
Calls the virtual valueChange() function if the new value is different from the previous value. The old value can still be retrieved using prevValue().
Reimplementado de QRangeControl.
QSizePolicy QSlider::sizePolicy | ( | ) | const [virtual] |
Reimplementado de QWidget.
QSizePolicy QSlider::sizePolicy | ( | ) | const [virtual] |
Reimplementado de QWidget.
void QSlider::sliderMoved | ( | int | value | ) | [signal] |
void QSlider::sliderMoved | ( | int | value | ) | [signal] |
This signal is emitted when the slider is dragged, with the new slider value as its argument.
void QSlider::sliderPressed | ( | ) | [signal] |
This signal is emitted when the user presses the slider with the mouse.
void QSlider::sliderPressed | ( | ) | [signal] |
QRect QSlider::sliderRect | ( | ) | const |
QRect QSlider::sliderRect | ( | ) | const |
Returns the slider handle rectangle. (This is the visual marker that the user can move.)
void QSlider::sliderReleased | ( | ) | [signal] |
This signal is emitted when the user releases the slider with the mouse.
void QSlider::sliderReleased | ( | ) | [signal] |
int QSlider::sliderStart | ( | ) | const |
int QSlider::sliderStart | ( | ) | const [inline] |
Returns the start position of the slider.
void QSlider::styleChange | ( | QStyle & | ) | [protected, virtual] |
This virtual function is called when the style of the widgets changes. oldStyle is the previous GUI style; you can get the new style from style().
Reimplement this function if your widget needs to know when its GUI style changes. You will almost certainly need to update the widget using update().
The default implementation updates the widget including its geometry.
Reimplementado de QWidget.
void QSlider::subtractLine | ( | ) | [slot] |
Reimplementado de QRangeControl.
void QSlider::subtractLine | ( | ) | [slot] |
Equivalent to {setValue( value() - lineStep() )}.
If the value is changed, then valueChange() is called.
Reimplementado de QRangeControl.
void QSlider::subtractStep | ( | ) | [slot] |
void QSlider::subtractStep | ( | ) | [slot] |
Moves the slider one pageStep() down or left.
int QSlider::tickInterval | ( | ) | const [inline] |
int QSlider::tickInterval | ( | ) | const [inline] |
TickSetting QSlider::tickmarks | ( | ) | const [inline] |
TickSetting QSlider::tickmarks | ( | ) | const [inline] |
bool QSlider::tracking | ( | ) | const |
bool QSlider::tracking | ( | ) | const |
int QSlider::value | ( | ) | const |
Returns the current range control value. This is guaranteed to be within the range [minValue(), maxValue()].
Reimplementado de QRangeControl.
int QSlider::value | ( | ) | const |
Returns the current range control value. This is guaranteed to be within the range [minValue(), maxValue()].
Reimplementado de QRangeControl.
void QSlider::valueChange | ( | ) | [protected, virtual] |
Implements the virtual QRangeControl function.
Reimplementado de QRangeControl.
void QSlider::valueChange | ( | ) | [protected, virtual] |
This virtual function is called whenever the range control value changes. You can reimplement it if you want to be notified when the value changes. The default implementation does nothing.
Note that this method is called after the value has changed. The previous value can be retrieved using prevValue().
Reimplementado de QRangeControl.
void QSlider::valueChanged | ( | int | value | ) | [signal] |
This signal is emitted when the slider value is changed, with the new slider value as its argument.
void QSlider::valueChanged | ( | int | value | ) | [signal] |
void QSlider::wheelEvent | ( | QWheelEvent * | e | ) | [protected, virtual] |
Reimplementado de QWidget.
void QSlider::wheelEvent | ( | QWheelEvent * | e | ) | [protected, virtual] |
This event handler, for event e, can be reimplemented in a subclass to receive wheel events for the widget.
If you reimplement this handler, it is very important that you ignore() the event if you do not handle it, so that the widget's parent can interpret it.
The default implementation ignores the event.
Reimplementado de QWidget.
int QSlider::lineStep [read, write] |
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.
int QSlider::maxValue [read, write] |
the current maximum value of the slider
When setting this property, the QSlider::minValue is adjusted, if necessary, to ensure that the range remains valid.
int QSlider::minValue [read, write] |
the current minimum value of the slider
When setting this property, the QSlider::maxValue is adjusted, if necessary, to ensure that the range remains valid.
QSlider::Orientation QSlider::orientation [inline, read, write] |
the slider's orientation
The orientation must be Qt::Vertical (the default) or Qt::Horizontal.
int QSlider::pageStep [read, write] |
the current page step
When setting pageStep, the virtual stepChange() function will be called if the new page step is different from the previous setting.
int QSlider::tickInterval [read, write] |
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.
TickSetting QSlider::tickmarks [read, write] |
the tickmark settings for this slider
The valid values are in {QSlider::TickSetting}. The default is NoMarks
.
bool QSlider::tracking [inline, read, write] |
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).
int QSlider::value [read, write] |
the current slider value