Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.trolltech.qt.gui
Class QScrollBar

    java.lang.Object
      com.trolltech.qt.internal.QSignalEmitterInternal
          com.trolltech.qt.QSignalEmitter
              com.trolltech.qt.QtJambiObject
                  com.trolltech.qt.core.QObject
                      com.trolltech.qt.gui.QWidget
                          com.trolltech.qt.gui.QAbstractSlider
                              com.trolltech.qt.gui.QScrollBar

All Implemented Interfaces:
  QPaintDeviceInterface, QtJambiInterface

    public class QScrollBar

extends QAbstractSlider

The `QScrollBar` widget provides a vertical or horizontal scroll bar. A scroll bar is a control that enables the user to access parts of a document that is larger than the widget used to display it. It provides a visual indication of the user's current position within the document and the amount of the document that is visible. Scroll bars are usually equipped with other controls that enable more accurate navigation. Qt displays scroll bars in a way that is appropriate for each platform.

If you need to provide a scrolling view onto another widget, it may be more convenient to use the `QScrollArea` class because this provides a viewport widget and scroll bars. `QScrollBar` is useful if you need to implement similar functionality for specialized widgets using `QAbstractScrollArea`; for example, if you decide to subclass `QAbstractItemView`. For most other situations where a slider control is used to obtain a value within a given range, the `QSlider` class may be more appropriate for your needs.

| Scroll bars typically include four separate controls: a slider, scroll arrows, and a page control. a. The slider provides a way to quickly go to any part of the document, but does not support accurate navigation within large documents. b. The scroll arrows are push buttons which can be used to accurately navigate to a particular place in a document. For a vertical scroll bar connected to a text editor, these typically move the current position one "line" up or down, and adjust the position of the slider by a small amount. In editors and list boxes a "line" might mean one line of text; in an image viewer it might mean 20 pixels. c. The page control is the area over which the slider is dragged (the scroll bar's background). Clicking here moves the scroll bar towards the click by one "page". This value is usually the same as the length of the slider.

Each scroll bar has a value that indicates how far the slider is from the start of the scroll bar; this is obtained with value() and set with setValue(). This value always lies within the range of values defined for the scroll bar, from `minimum()` to `maximum()` inclusive. The range of acceptable values can be set with setMinimum() and setMaximum(). At the minimum value, the top edge of the slider (for a vertical scroll bar) or left edge (for a horizontal scroll bar) will be at the top (or left) end of the scroll bar. At the maximum value, the bottom (or right) edge of the slider will be at the bottom (or right) end of the scroll bar.

The length of the slider is usually related to the value of the page step, and typically represents the proportion of the document area shown in a scrolling view. The page step is the amount that the value changes by when the user presses the Page Up and Page Down keys, and is set with setPageStep(). Smaller changes to the value defined by the line step are made using the cursor keys, and this quantity is set with `setSingleStep()`.

Note that the range of values used is independent of the actual size of the scroll bar widget. You do not need to take this into account when you choose values for the range and the page step.

The range of values specified for the scroll bar are often determined differently to those for a `QSlider` because the length of the slider needs to be taken into account. If we have a document with 100 lines, and we can only show 20 lines in a widget, we may wish to construct a scroll bar with a page step of 20, a minimum value of 0, and a maximum value of 80. This would give us a scroll bar with five "pages".

| The relationship between a document length, the range of values used in a scroll bar, and the page step is simple in many common situations. The scroll bar's range of values is determined by subtracting a chosen page step from some value representing the length of the document. In such cases, the following equation is useful: document length = maximum() - minimum() + pageStep().

`QScrollBar` only provides integer ranges. Note that although `QScrollBar` handles very large numbers, scroll bars on current screens cannot usefully represent ranges above about 100,000 pixels. Beyond that, it becomes difficult for the user to control the slider using either the keyboard or the mouse, and the scroll arrows will have limited use.

ScrollBar inherits a comprehensive set of signals from `QAbstractSlider`:

- `valueChanged()` is emitted when the scroll bar's value has changed. The tracking() determines whether this signal is emitted during user interaction.
- `rangeChanged()` is emitted when the scroll bar's range of values has changed.
- `sliderPressed()` is emitted when the user starts to drag the slider.
- `sliderMoved()` is emitted when the user drags the slider.
- `sliderReleased()` is emitted when the user releases the slider.
- `actionTriggered()` is emitted when the scroll bar is changed by user interaction or via the `triggerAction()` function.

A scroll bar can be controlled by the keyboard, but it has a default focusPolicy() of `Qt::NoFocus` . Use setFocusPolicy() to enable keyboard interaction with the scroll bar:

- Left/Right move a horizontal scroll bar by one single step.
- Up/Down move a vertical scroll bar by one single step.
- PageUp moves up one page.
- PageDown moves down one page.
- Home moves to the start (mininum).
- End moves to the end (maximum).

The slider itself can be controlled by using the `triggerAction()` function to simulate user interaction with the scroll bar controls. This is useful if you have many different widgets that use a common range of values.

Most GUI styles use the pageStep() value to calculate the size of the slider.

| A scroll bar shown in the Macintosh widget style.
| A scroll bar shown in the Windows XP widget style.
| A scroll bar shown in the Plastique widget style.

See also:
  `QScrollArea`, `QSlider`, `QDial`, `QSpinBox`, GUI Design Handbook: Scroll Bar, and Sliders Example.

Nested Class Summary

Nested classes/interfaces inherited from class com.trolltech.qt.gui.QAbstractSlider
`QAbstractSlider.SliderAction, QAbstractSlider.SliderChange`

Nested classes/interfaces inherited from class com.trolltech.qt.gui.QWidget
`QWidget.RenderFlag, QWidget.RenderFlags`

Nested classes/interfaces inherited from class com.trolltech.qt.QSignalEmitter
`QSignalEmitter.AbstractSignal, QSignalEmitter.Signal0, QSignalEmitter.Signal1, QSignalEmitter.Signal2, QSignalEmitter.Signal3, QSignalEmitter.Signal4, QSignalEmitter.Signal5, QSignalEmitter.Signal6, QSignalEmitter.Signal7, QSignalEmitter.Signal8, QSignalEmitter.Signal9`

Nested classes/interfaces inherited from class com.trolltech.qt.internal.QSignalEmitterInternal
`com.trolltech.qt.internal.QSignalEmitterInternal.AbstractSignalInternal`

Field Summary

Fields inherited from class com.trolltech.qt.gui.QAbstractSlider
`actionTriggered, rangeChanged, sliderMoved, sliderPressed, sliderReleased, valueChanged`

Fields inherited from class com.trolltech.qt.gui.QWidget
`customContextMenuRequested`

Fields inherited from class com.trolltech.qt.internal.QSignalEmitterInternal
`currentSender`

Constructor Summary
`QScrollBar()` Constructs a vertical scroll bar.
`QScrollBar(Qt.Orientation arg__1)` Constructs a scroll bar with the given `orientation`.
`QScrollBar(Qt.Orientation arg__1, QWidget parent)` Constructs a scroll bar with the given `orientation`.
`QScrollBar(QWidget parent)` Constructs a vertical scroll bar.

Method Summary
`protected void` | `initStyleOption(QStyleOptionSlider option)` Initialize `option` with the values from this QScrollBar.

Methods inherited from class com.trolltech.qt.gui.QAbstractSlider
`hasTracking, invertedAppearance, invertedControls, isSliderDown, maximum, minimum, orientation, pageStep, repeatAction, setInvertedAppearance, setInvertedControls, setMaximum, setMinimum, setOrientation, setPageStep, setRange, setRepeatAction, setRepeatAction, setRepeatAction, setSingleStep, setSliderDown, setSliderPosition, setTracking, setValue, singleStep, sliderChange, sliderPosition, triggerAction, value`

Methods inherited from class com.trolltech.qt.gui.QWidget
`acceptDrops, accessibleDescription, accessibleName, actionEvent, actions, activateWindow, addAction, addActions, adjustSize, autoFillBackground, backgroundRole, baseSize, changeEvent, childAt, childAt, childrenRect, childrenRegion, clearFocus, clearMask, close, closeEvent, contentsRect, contextMenuEvent, contextMenuPolicy, cursor, depth, destroy, destroy, destroy, dragEnterEvent, dragLeaveEvent, dragMoveEvent, dropEvent, effectiveWinId, ensurePolished, enterEvent, focusInEvent, focusNextChild, focusNextPrevChild, focusOutEvent, focusPolicy, focusPreviousChild, focusProxy, focusWidget, font, fontInfo, fontMetrics, foregroundRole, frameGeometry, frameSize, geometry, getContentsMargins, grabKeyboard, grabMouse, grabMouse, grabShortcut, grabShortcut, hasFocus, hasMouseTracking, height, heightForWidth, heightMM, hide, hideEvent, inputContext, inputMethodEvent, inputMethodQuery, insertAction, insertActions, isActiveWindow, isAncestorOf, isEnabled, isEnabledTo, isFullScreen, isHidden, isMaximized, isMinimized, isModal, isVisible, isVisibleTo, isWindow, isWindowModified, keyboardGrabber, keyPressEvent, keyReleaseEvent, languageChange, layout, layoutDirection, leaveEvent, locale, logicalDpiX, logicalDpiY, lower, mapFrom, mapFromGlobal, mapFromParent, mapTo, mapToGlobal, mapToParent, mask, maximumHeight, maximumSize, maximumWidth, metric, minimumHeight, minimumSize, minimumSizeHint, minimumWidth, mouseDoubleClickEvent, mouseGrabber, mouseMoveEvent, mousePressEvent, mouseReleaseEvent, move, move, moveEvent, nativeParentWidget, nextInFocusChain, normalGeometry, numColors, overrideWindowFlags, overrideWindowFlags, paintEngine, paintEvent, paintingActive, palette, parentWidget, physicalDpiX, physicalDpiY, pos, raise, rect, releaseKeyboard, releaseMouse, releaseShortcut, removeAction, render, render, render, render, render, render, render, render, render, repaint, repaint, repaint, repaint, resetInputContext, resize, resize, resizeEvent, restoreGeometry, saveGeometry, scroll, scroll, setAcceptDrops, setAccessibleDescription, setAccessibleName, setAttribute, setAttribute, setAutoFillBackground, setBackgroundRole, setBaseSize, setBaseSize, setContentsMargins, setContentsMargins, setContextMenuPolicy, setCursor, setDisabled, setEnabled, setFixedHeight, setFixedSize, setFixedSize, setFixedWidth, setFocus, setFocus, setFocusPolicy, setFocusProxy, setFont, setForegroundRole, setGeometry, setGeometry, setHidden, setInputContext, setLayout, setLayoutDirection, setLocale, setMask, setMask, setMaximumHeight, setMaximumSize, setMaximumSize, setMaximumWidth, setMinimumHeight, setMinimumSize, setMinimumSize, setMinimumWidth, setMouseTracking, setPalette, setParent, setParent, setParent, setShortcutAutoRepeat, setShortcutAutoRepeat, setShortcutEnabled, setShortcutEnabled, setSizeIncrement, setSizeIncrement, setSizePolicy, setSizePolicy, setStatusTip, setStyle, setStyleSheet, setTabOrder, setToolTip, setUpdatesEnabled, setVisible, setWhatsThis, setWindowFilePath, setWindowFlags, setWindowFlags, setWindowIcon, setWindowIconText, setWindowModality, setWindowModified, setWindowOpacity, setWindowRole, setWindowState, setWindowState, setWindowTitle, show, showEvent, showFullScreen, showMaximized, showMinimized, showNormal, size, sizeHint, sizeIncrement, sizePolicy, stackUnder, statusTip, style, styleSheet, tabletEvent, testAttribute, toolTip, underMouse, unsetCursor, unsetLayoutDirection, unsetLocale, update, update, update, update, updateGeometry, updateMicroFocus, updatesEnabled, visibleRegion, whatsThis, wheelEvent, width, widthMM, window, windowFilePath, windowFlags, windowIcon, windowIconText, windowModality, windowOpacity, windowRole, windowState, windowTitle, windowType, winId, x, y`

Methods inherited from class com.trolltech.qt.core.QObject
`childEvent, children, connectSlotsByName, customEvent, disposeLater, dumpObjectInfo, dumpObjectTree, dynamicPropertyNames, event, eventFilter, findChild, findChild, findChild, findChildren, findChildren, findChildren, findChildren, indexOfProperty, installEventFilter, isWidgetType, killTimer, moveToThread, objectName, parent, properties, property, removeEventFilter, setObjectName, setParent, setProperty, startTimer, timerEvent, toString, userProperty`

Methods inherited from class com.trolltech.qt.QtJambiObject
`dispose, disposed, equals, finalize, reassignNativeResources, tr, tr, tr`

Methods inherited from class com.trolltech.qt.QSignalEmitter
`blockSignals, disconnect, disconnect, signalsBlocked, signalSender, thread`

Methods inherited from class com.trolltech.qt.internal.QSignalEmitterInternal
`__qt_signalInitialization`

Methods inherited from class java.lang.Object
`clone, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Methods inherited from interface com.trolltech.qt.QtJambiInterface
`disableGarbageCollection, nativeId, nativePointer, reenableGarbageCollection, setJavaOwnership`

Constructor Detail

### QScrollBar

    public QScrollBar()

  Constructs a vertical scroll bar.

  The `parent` arguments 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.

### QScrollBar

    public QScrollBar(QWidget parent)

  Constructs a vertical scroll bar.

  The `parent` arguments 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.

### QScrollBar

    public QScrollBar(Qt.Orientation arg__1)

  Constructs a scroll bar with the given `orientation`.

  The `parent` argument is passed 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.

### QScrollBar

    public QScrollBar(Qt.Orientation arg__1,
                      QWidget parent)

  Constructs a scroll bar with the given `orientation`.

  The `parent` argument is passed 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.

Method Detail

### initStyleOption

    protected final void initStyleOption(QStyleOptionSlider option)

  Initialize `option` with the values from this QScrollBar. This method is useful for subclasses when they need a QStyleOptionButton, but don't want to fill in all the information themselves.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD