Qt:Документация 4.3.2/qscrollbar

Материал из Wiki.crossplatform.ru

Перейти к: навигация, поиск
40px Внимание: Актуальная версия перевода документации находится здесь

__NOTOC__

Image:qt-logo.png

Главная · Все классы · Основные классы · Классы по группам · Модули · Функции

Image:trolltech-logo.png

Содержание

QScrollBar Class Reference
[модуль QtGui ]

Виджет QScrollBar - это вертикальная или горизонтальная полоса прокрутки. More...

 #include <QScrollBar>

Наследует QAbstractSlider.

Открытые функции

  • 22 открытых функций унаследованных от QAbstractSlider
  • 201 открытых функций унаследованных от QWidget
  • 29 открытых функций унаследованных от QObject
  • 12 открытых функций унаследованных от QPaintDevice

Защищенные функции

  • 3 защищенных функций унаследованных от QAbstractSlider
  • 38 защищенных функций унаследованных от QWidget
  • 7 защищенных функций унаследованных от QObject
  • 1 защищенная функция унаследованна от QPaintDevice

Дополнительные унаследованные члены

  • 11 свойства унаследованных от QAbstractSlider
  • 56 свойства унаследованных от QWidget
  • 1 свойство унаследованное от QObject
  • 2 открытых слотов унаследованных от QAbstractSlider
  • 19 открытых слотов унаследованных от QWidget
  • 1 открытый слот унаследованный от QObject
  • 6 сигнала унаследованных от QAbstractSlider
  • 1 сигнал унаследованный от QWidget
  • 1 сигнал унаследованный от QObject
  • 4 статических открытых члена унаследованных от QWidget
  • 5 статических открытых члена унаследованных от QObject
  • 1 защищенный слот унаследованный от QWidget

Подробное описание

Виджет QScrollBar - это вертикальная или горизонтальная полоса прокрутки.

Полоса прокрутки - это элемент управления, который предоставляет пользователю доступ к частям документа, по размеру превосходящего виджет, на котором от отображается. Также полоса прокрутки показывает пользователю его текущее положение в документе и примерный размер отображаемой части относительно всего документа. Нередко полосы прокрутки снабжаются дополнительными "рюшечками", которые позволяют осуществлять более точное позиционирование. Qt отображает полосы прокрутки в таком виде, который является наиболее подходящим для конкретной платформы.

Если Вам нужно создать область, управляемую полосами прокрутки на другом виджете, то, возможно, более удобной альтернативой будет использование виджета QScrollArea, потому что он предоставляет ограниченную масштабируемую область обзора с вертикальной и горизонтальной полосами прокрутки. QScrollBar также будет полезен, если вы хотите реализовать подобную функциональность для специального виджета, используя QAbstractScrollArea; например, если Вы решите создать подкласс для QAbstractItemView. Для большинства других ситуаций, где нужно получать значение из заданного интервала, Вам скорее всего больше подойдёт QSlider.


Файл:Qscrollbar-picture.png

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 setLineStep().

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".


Файл:Qscrollbar-values.png 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:

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.


center A scroll bar shown in the Macintosh widget style.
center A scroll bar shown in the Windows XP widget style.
Файл:Plastique-horizontalscrollbar.png A scroll bar shown in the Plastique widget style.

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


Описание функций-членов

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.

void QScrollBar::initStyleOption ( QStyleOptionSlider * option ) const [protected]

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

See also QStyleOption::initFrom().


Copyright © 2007 Trolltech Trademarks
Qt 4.3.2