Home | All Classes | Main Classes | Annotated | Grouped Classes | Functions |

# QScrollBar Class Reference

The QScrollBar widget provides a vertical or horizontal scroll bar. More...

    #include <QScrollBar>

Inherits QAbstractSlider.

- List of all members, including inherited members
- Compatibility members

### Writable Properties

- 10 writable properties inherited from QAbstractSlider
- 33 writable properties inherited from QWidget
- 1 writable property inherited from QObject

### Read-Only Properties

- 24 read-only properties inherited from QWidget

### Public Functions

- QScrollBar ( QWidget * parent = 0 )
- QScrollBar ( Qt::Orientation orientation, QWidget * parent = 0 )
- ~QScrollBar ()

- 4 public functions inherited from QAbstractSlider
- 83 public functions inherited from QWidget
- 24 public functions inherited from QObject
- 2 public functions inherited from QPaintDevice

### Public Slots

- 1 public slot inherited from QAbstractSlider
- 16 public slots inherited from QWidget
- 1 public slot inherited from QObject

### Signals

- 6 signals inherited from QAbstractSlider
- 1 signal inherited from QObject

### Static Public Members

- 4 static public members inherited from QWidget
- 4 static public members inherited from QObject

### Protected Functions

- 3 protected functions inherited from QAbstractSlider
- 44 protected functions inherited from QWidget
- 9 protected functions inherited from QObject

## Detailed Description

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.

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 QAbstractSlider. The most useful functions are setValue() to set the scroll bar directly to some value; triggerAction() to simulate the effects of clicking (useful for shortcut keys); setSingleStep(), setPageStep() to set the steps; and setMinimum() and setMaximum() to define the range of the scroll bar.

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.

ScrollBar inherits 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.

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 `Qt::NoFocus`. Use setFocusPolicy() to enable keyboard interaction with the scrollbar:

- Left/Right move a horizontal scrollbar by one single step.
- Up/Down move a vertical scrollbar 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).

If you need to add scroll bars to an interface, consider using the QScrollView class, which encapsulates the common uses for scroll bars.

GUI Design Handbook: Scroll Bar

See also QSlider, QSpinBox, and QScrollView.

## Member Function Documentation

### QScrollBar::QScrollBar ( QWidget * parent = 0 )

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::QScrollBar ( Qt::Orientation orientation, QWidget * parent = 0 )

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::~QScrollBar ()

Destroys the scroll bar.