Eneboo - Documentación para desarrolladores
|
The QScrollBar widget provides a vertical or horizontal scroll bar. Más...
#include <qscrollbar.h>
The QScrollBar widget provides a vertical or horizontal scroll bar.
A scroll bar allows the user to control a value within a program-definable range and gives users a visible indication of the current value of a range control .
Scroll bars include four separate controls:
The line-up and line-down controls are little buttons which the user can use to move one "line" up or down. The meaning of line is configurable. In editors and list boxes it means one line of text; in an image viewer it might mean 20 pixels.
The slider is the handle that indicates the current value of the scroll bar, which the user can drag to change the value. This part of the scroll bar is sometimes called the "thumb".
The page-up/page-down control is the area on which the slider slides (the scroll bar's background). Clicking here moves the scroll bar towards the click. The meaning of "page" is also configurable: in editors and list boxes it means as many lines as there is space for in the widget.
QScrollBar has very few of its own functions; it mostly relies on QRangeControl. The most useful functions are setValue() to set the scroll bar directly to some value; addPage(), addLine(), subtractPage(), and subtractLine() to simulate the effects of clicking (useful for accelerator keys); setSteps() to define the values of pageStep() and lineStep(); and setRange() to set the minValue() and maxValue() of the scroll bar. QScrollBar has a convenience constructor with which you can set most of these properties.
Some GUI styles (for example, the Windows and Motif styles provided with Qt), also use the pageStep() value to calculate the size of the slider.
In addition to the access functions from QRangeControl, QScrollBar provides a comprehensive set of signals: Signal Emitted when valueChanged() the scroll bar's 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. nextLine() the scroll bar has moved one line down or right. Line is defined in QRangeControl. prevLine() the scroll bar has moved one line up or left. nextPage() the scroll bar has moved one page down or right. prevPage() the scroll bar has moved one page up or left.
QScrollBar only provides integer ranges. Note that although QScrollBar handles very large numbers, scroll bars on current screens cannot usefully control ranges above about 100,000 pixels. Beyond that, it becomes difficult for the user to control the scroll bar using either the keyboard or the mouse.
A scroll bar can be controlled by the keyboard, but it has a default focusPolicy() of NoFocus
. Use setFocusPolicy() to enable keyboard focus. See keyPressEvent() for a list of key bindings.
If you need to add scroll bars to an interface, consider using the QScrollView class, which encapsulates the common uses for scroll bars.
QScrollBar::QScrollBar | ( | QWidget * | parent, |
const char * | name = 0 |
||
) |
Constructs a vertical scroll bar.
The parent and name arguments are sent on to the QWidget constructor.
The minValue
defaults to 0, the maxValue
to 99, with a lineStep
size of 1 and a pageStep
size of 10, and an initial value
of 0.
QScrollBar::QScrollBar | ( | Orientation | orientation, |
QWidget * | parent, | ||
const char * | name = 0 |
||
) |
Constructs a scroll bar.
The orientation must be Qt::Vertical
or Qt::Horizontal
.
The parent and name arguments are sent on to the QWidget constructor.
The minValue
defaults to 0, the maxValue
to 99, with a lineStep
size of 1 and a pageStep
size of 10, and an initial value
of 0.
QScrollBar::QScrollBar | ( | int | minValue, |
int | maxValue, | ||
int | lineStep, | ||
int | pageStep, | ||
int | value, | ||
Orientation | orientation, | ||
QWidget * | parent, | ||
const char * | name = 0 |
||
) |
Constructs a scroll bar whose value can never be smaller than minValue or greater than maxValue, whose line step size is lineStep and page step size is pageStep and whose value is initially value (which is guaranteed to be in range using bound()).
If orientation is Vertical
the scroll bar is vertical and if it is Horizontal
the scroll bar is horizontal.
The parent and name arguments are sent on to the QWidget constructor.
QScrollBar::~QScrollBar | ( | ) |
Destructor.
QScrollBar::QScrollBar | ( | QWidget * | parent, |
const char * | name = 0 |
||
) |
QScrollBar::QScrollBar | ( | Orientation | , |
QWidget * | parent, | ||
const char * | name = 0 |
||
) |
QScrollBar::QScrollBar | ( | int | minValue, |
int | maxValue, | ||
int | lineStep, | ||
int | pageStep, | ||
int | value, | ||
Orientation | , | ||
QWidget * | parent, | ||
const char * | name = 0 |
||
) |
QScrollBar::~QScrollBar | ( | ) |
void QScrollBar::contextMenuEvent | ( | QContextMenuEvent * | e | ) | [protected, virtual] |
Reimplementado de QWidget.
void QScrollBar::contextMenuEvent | ( | QContextMenuEvent * | e | ) | [protected, virtual] |
This event handler, for event e, can be reimplemented in a subclass to receive widget context menu events.
The default implementation calls e->ignore(), which rejects the context event. See the QContextMenuEvent documentation for more details.
Reimplementado de QWidget.
bool QScrollBar::draggingSlider | ( | ) | const |
bool QScrollBar::draggingSlider | ( | ) | const |
void QScrollBar::hideEvent | ( | QHideEvent * | ) | [protected, virtual] |
This function is called when the scrollbar is hidden.
Reimplementado de QWidget.
void QScrollBar::hideEvent | ( | QHideEvent * | ) | [protected, virtual] |
This event handler can be reimplemented in a subclass to receive widget hide events.
Hide events are sent to widgets immediately after they have been hidden.
Reimplementado de QWidget.
void QScrollBar::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 QScrollBar::lineStep | ( | ) | const |
int QScrollBar::lineStep | ( | ) | const |
int QScrollBar::maxValue | ( | ) | const |
Returns the maximum value of the range.
Reimplementado de QRangeControl.
int QScrollBar::maxValue | ( | ) | const |
Returns the maximum value of the range.
Reimplementado de QRangeControl.
int QScrollBar::minValue | ( | ) | const |
Returns the minimum value of the range.
Reimplementado de QRangeControl.
int QScrollBar::minValue | ( | ) | const |
Returns the minimum value of the range.
Reimplementado de QRangeControl.
void QScrollBar::mouseMoveEvent | ( | QMouseEvent * | e | ) | [protected, virtual] |
Reimplementado de QWidget.
void QScrollBar::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 QScrollBar::mousePressEvent | ( | QMouseEvent * | e | ) | [protected, virtual] |
Reimplementado de QWidget.
void QScrollBar::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 QScrollBar::mouseReleaseEvent | ( | QMouseEvent * | e | ) | [protected, virtual] |
Reimplementado de QWidget.
void QScrollBar::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.
void QScrollBar::nextLine | ( | ) | [signal] |
void QScrollBar::nextLine | ( | ) | [signal] |
This signal is emitted when the scroll bar scrolls one line down or right.
void QScrollBar::nextPage | ( | ) | [signal] |
void QScrollBar::nextPage | ( | ) | [signal] |
This signal is emitted when the scroll bar scrolls one page down or right.
Orientation QScrollBar::orientation | ( | ) | const |
Orientation QScrollBar::orientation | ( | ) | const |
int QScrollBar::pageStep | ( | ) | const |
int QScrollBar::pageStep | ( | ) | const |
void QScrollBar::paintEvent | ( | QPaintEvent * | ) | [protected, virtual] |
Reimplementado de QWidget.
void QScrollBar::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 QScrollBar::prevLine | ( | ) | [signal] |
void QScrollBar::prevLine | ( | ) | [signal] |
This signal is emitted when the scroll bar scrolls one line up or left.
void QScrollBar::prevPage | ( | ) | [signal] |
void QScrollBar::prevPage | ( | ) | [signal] |
This signal is emitted when the scroll bar scrolls one page up or left.
void QScrollBar::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 QScrollBar::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 QScrollBar::resizeEvent | ( | QResizeEvent * | ) | [protected, virtual] |
Reimplementado de QWidget.
void QScrollBar::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 QScrollBar::setLineStep | ( | int | i | ) |
void QScrollBar::setLineStep | ( | int | ) |
void QScrollBar::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 QScrollBar::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 QScrollBar::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 QScrollBar::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 QScrollBar::setOrientation | ( | Orientation | orientation | ) | [virtual] |
virtual void QScrollBar::setOrientation | ( | Orientation | ) | [virtual] |
void QScrollBar::setPageStep | ( | int | i | ) |
void QScrollBar::setPageStep | ( | int | ) |
void QScrollBar::setPalette | ( | const QPalette & | p | ) | [virtual] |
Reimplements the virtual function QWidget::setPalette().
Sets the background color to the mid color for Motif style scroll bars using palette p.
Reimplementado de QWidget.
void QScrollBar::setSizePolicy | ( | QSizePolicy | sp | ) | [virtual] |
Reimplementado de QWidget.
void QScrollBar::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.
virtual void QScrollBar::setSizePolicy | ( | QSizePolicy | sp | ) | [virtual] |
Reimplementado de QWidget.
void QScrollBar::setSizePolicy | ( | QSizePolicy::SizeType | hor, |
QSizePolicy::SizeType | ver, | ||
bool | hfw = FALSE |
||
) | [inline] |
Reimplementado de QWidget.
virtual void QScrollBar::setTracking | ( | bool | enable | ) | [virtual] |
void QScrollBar::setTracking | ( | bool | enable | ) | [inline, virtual] |
void QScrollBar::setValue | ( | int | value | ) | [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 QScrollBar::setValue | ( | int | value | ) | [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 QScrollBar::sliderMoved | ( | int | value | ) | [signal] |
This signal is emitted when the slider is dragged by the user, with the new scroll bar value as an argument.
This signal is emitted even when tracking is turned off.
void QScrollBar::sliderMoved | ( | int | value | ) | [signal] |
void QScrollBar::sliderPressed | ( | ) | [signal] |
void QScrollBar::sliderPressed | ( | ) | [signal] |
This signal is emitted when the user presses the slider with the mouse.
QRect QScrollBar::sliderRect | ( | ) | const |
QRect QScrollBar::sliderRect | ( | ) | const |
Returns the scroll bar slider rectangle.
void QScrollBar::sliderReleased | ( | ) | [signal] |
void QScrollBar::sliderReleased | ( | ) | [signal] |
This signal is emitted when the user releases the slider with the mouse.
int QScrollBar::sliderStart | ( | ) | const [inline] |
Returns the pixel position where the scroll bar slider starts.
This is equivalent to sliderRect().y() for vertical scroll bars or sliderRect().x() for horizontal scroll bars.
int QScrollBar::sliderStart | ( | ) | const |
void QScrollBar::stepChange | ( | ) | [protected, virtual] |
This virtual function is called whenever the range control's line or page step settings change. You can reimplement it if you want to be notified when the step changes. The default implementation does nothing.
Note that this method is called after a step setting has changed.
Reimplementado de QRangeControl.
void QScrollBar::stepChange | ( | ) | [protected, virtual] |
This virtual function is called whenever the range control's line or page step settings change. You can reimplement it if you want to be notified when the step changes. The default implementation does nothing.
Note that this method is called after a step setting has changed.
Reimplementado de QRangeControl.
void QScrollBar::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.
bool QScrollBar::tracking | ( | ) | const |
bool QScrollBar::tracking | ( | ) | const |
int QScrollBar::value | ( | ) | const |
Returns the current range control value. This is guaranteed to be within the range [minValue(), maxValue()].
Reimplementado de QRangeControl.
int QScrollBar::value | ( | ) | const |
Returns the current range control value. This is guaranteed to be within the range [minValue(), maxValue()].
Reimplementado de QRangeControl.
void QScrollBar::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 QScrollBar::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 QScrollBar::valueChanged | ( | int | value | ) | [signal] |
This signal is emitted when the scroll bar value has changed, with the new scroll bar value as an argument.
void QScrollBar::valueChanged | ( | int | value | ) | [signal] |
void QScrollBar::wheelEvent | ( | QWheelEvent * | e | ) | [protected, virtual] |
Reimplementado de QWidget.
void QScrollBar::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.
bool QScrollBar::draggingSlider [read] |
whether the user has clicked the mouse on the slider and is currently dragging it
int QScrollBar::lineStep [read, write] |
the line step
When setting lineStep, the virtual stepChange() function will be called if the new line step is different from the previous setting.
int QScrollBar::maxValue [read, write] |
the scroll bar's maximum value
When setting this property, the QScrollBar::minValue is adjusted if necessary to ensure that the range remains valid.
int QScrollBar::minValue [read, write] |
the scroll bar's minimum value
When setting this property, the QScrollBar::maxValue is adjusted if necessary to ensure that the range remains valid.
QScrollBar::Orientation QScrollBar::orientation [inline, read, write] |
the orientation of the scroll bar
The orientation must be Qt::Vertical (the default) or Qt::Horizontal.
int QScrollBar::pageStep [read, write] |
the page step
When setting pageStep, the virtual stepChange() function will be called if the new page step is different from the previous setting.
bool QScrollBar::tracking [inline, read, write] |
whether scroll bar tracking is enabled
If tracking is enabled (the default), the scroll bar emits the valueChanged() signal while the slider is being dragged. If tracking is disabled, the scroll bar emits the valueChanged() signal only when the user releases the mouse button after moving the slider.
int QScrollBar::value [read, write] |
the scroll bar's value