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.

Writable Properties

Read-Only Properties

Public Functions

Public Slots

Signals

Static Public Members

Protected Functions


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:

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:

SignalEmitted 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:

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

Screenshot in Motif style Screenshot in Windows style

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.


Copyright © 2004 Trolltech. Trademarks
Qt 4.0.0-tp1