#include <qabstractscrollarea.h>
Inheritance diagram for QAbstractScrollArea:


QAbstractScrollArea is a low-level abstraction of a scrolling area. It gives you full control of the scroll bars, at the cost of simplicity. In most cases, using a QScrollArea is preferable.
QAbstractScrollArea's central child widget is the scrolling area itself, called viewport(). The viewport widget uses all available space. Next to the viewport is a vertical scroll bar (accessible with verticalScrollBar()), and below a horizontal scroll bar (accessible with horizontalScrollBar()). Each scroll bar can be either visible or hidden, depending on the scroll bar's policy (see verticalScrollBarPolicy and horizontalScrollBarPolicy). When a scroll bar is hidden, the viewport expands in order to cover all available space. When a scroll bar becomes visible again, the viewport shrinks in order to make room for the scroll bar.
With a scroll bar policy of Qt::ScrollBarAsNeeded (the default), QAbstractScrollArea shows scroll bars when those provide a non-zero scrolling range, and hides them otherwise. You control the range of each scroll bar with QAbstractSlider::setRange().
In order to track scroll bar movements, reimplement the virtual function scrollContentsBy(). In order to fine-tune scrolling behavior, connect to a scroll bar's QAbstractSlider::actionTriggered() signal and adjust the QAbstractSlider::sliderPosition as you wish.
It is possible to reserve a margin area around the viewport, see setViewportMargins(). The feature is mostly used to place a QHeaderView widget above or beside the scrolling area.
For convenience, QAbstractScrollArea makes all viewport events available in the virtual viewportEvent() handler. QWidget's specialized handlers are remapped to viewport events in the cases where this makes sense. The remapped specialized handlers are: paintEvent(), mousePressEvent(), mouseReleaseEvent(), mouseDoubleClickEvent(), mouseMoveEvent(), wheelEvent(), dragEnterEvent(), dragMoveEvent(), dragLeaveEvent(), dropEvent(), contextMenuEvent(). and resizeEvent().
Definition at line 38 of file qabstractscrollarea.h.
| QAbstractScrollArea::QAbstractScrollArea | ( | QWidget * | parent = 0 |
) | [explicit] |
Constructs a viewport.
The parent arguments is sent to the QWidget constructor.
Definition at line 395 of file qabstractscrollarea.cpp.
References d.
00396 :QFrame(*new QAbstractScrollAreaPrivate, parent) 00397 { 00398 Q_D(QAbstractScrollArea); 00399 d->init(); 00400 }
| QAbstractScrollArea::~QAbstractScrollArea | ( | ) |
Destroys the viewport.
Definition at line 406 of file qabstractscrollarea.cpp.
References d.
00407 { 00408 Q_D(QAbstractScrollArea); 00409 delete d->viewportFilter; 00410 }
| QAbstractScrollArea::QAbstractScrollArea | ( | QAbstractScrollAreaPrivate & | dd, | |
| QWidget * | parent = 0 | |||
| ) | [protected] |
Definition at line 383 of file qabstractscrollarea.cpp.
References d.
00384 :QFrame(dd, parent) 00385 { 00386 Q_D(QAbstractScrollArea); 00387 d->init(); 00388 }
| Qt::ScrollBarPolicy QAbstractScrollArea::verticalScrollBarPolicy | ( | ) | const |
Definition at line 486 of file qabstractscrollarea.cpp.
References d.
Referenced by QListView::updateGeometries().
00487 { 00488 Q_D(const QAbstractScrollArea); 00489 return d->vbarpolicy; 00490 }
| void QAbstractScrollArea::setVerticalScrollBarPolicy | ( | Qt::ScrollBarPolicy | ) |
Definition at line 492 of file qabstractscrollarea.cpp.
References d, and QWidget::isVisible().
Referenced by EditorPage::addPluralForm(), EditorPage::EditorPage(), QHeaderView::initialize(), KAsteroidsView::KAsteroidsView(), qdesigner_internal::ObjectInspector::ObjectInspector(), OublietteView::OublietteView(), QCalendarView::QCalendarView(), qdesigner_internal::QtGradientStopsWidget::QtGradientStopsWidget(), QComboBox::setEditable(), and QComboBoxPrivateContainer::setItemView().
00493 { 00494 Q_D(QAbstractScrollArea); 00495 d->vbarpolicy = policy; 00496 if (isVisible()) 00497 d->layoutChildren(); 00498 }
Here is the call graph for this function:

| QScrollBar * QAbstractScrollArea::verticalScrollBar | ( | ) | const |
Returns the vertical scroll bar.
Definition at line 506 of file qabstractscrollarea.cpp.
References d.
Referenced by QGraphicsView::centerOn(), QAbstractItemView::doAutoScroll(), QGraphicsView::ensureVisible(), PieView::indexAt(), TextEdit::keyPressEvent(), SvgWindow::mouseMoveEvent(), PreviewView::mouseMoveEvent(), QGraphicsView::mouseMoveEvent(), PreviewView::mousePressEvent(), SvgWindow::mousePressEvent(), PreviewView::paintEvent(), PieView::paintEvent(), PieView::PieView(), PreviewView::PreviewView(), QAccessibleTextEdit::rect(), PreviewView::resizeEvent(), QTableView::rowCountChanged(), ImageViewer::scaleImage(), QListView::scrollContentsBy(), QTableView::scrollContentsBy(), QTreeView::scrollContentsBy(), QComboBoxPrivateContainer::scrollItemView(), QListView::scrollTo(), QTableView::scrollTo(), PieView::scrollTo(), QTreeView::scrollTo(), QAbstractItemView::scrollToBottom(), OublietteView::scrollToCharacter(), QAbstractItemView::scrollToTop(), qdesigner_internal::ObjectInspector::setFormWindow(), QComboBoxPrivateContainer::setItemView(), PieView::setSelection(), QListView::updateGeometries(), PieView::updateGeometries(), QTableView::updateGeometries(), QComboBoxPrivateContainer::updateScrollers(), QTreeView::verticalOffset(), PieView::verticalOffset(), QListView::verticalOffset(), QAbstractItemView::verticalScrollbarValueChanged(), View::View(), and PieView::visualRect().
00507 { 00508 Q_D(const QAbstractScrollArea); 00509 return d->vbar; 00510 }
| void QAbstractScrollArea::setVerticalScrollBar | ( | QScrollBar * | scrollBar | ) |
Definition at line 524 of file qabstractscrollarea.cpp.
References d, qWarning(), and Qt::Vertical.
00525 { 00526 Q_D(QAbstractScrollArea); 00527 if (!scrollBar) { 00528 qWarning("QAbstractScrollArea::setVerticalScrollBar: Cannot set a null scroll bar"); 00529 return; 00530 } 00531 00532 d->replaceScrollBar(scrollBar, Qt::Vertical); 00533 }
Here is the call graph for this function:

| Qt::ScrollBarPolicy QAbstractScrollArea::horizontalScrollBarPolicy | ( | ) | const |
Definition at line 544 of file qabstractscrollarea.cpp.
References d.
Referenced by QComboBox::showPopup(), and QListView::updateGeometries().
00545 { 00546 Q_D(const QAbstractScrollArea); 00547 return d->hbarpolicy; 00548 }
| void QAbstractScrollArea::setHorizontalScrollBarPolicy | ( | Qt::ScrollBarPolicy | ) |
Definition at line 550 of file qabstractscrollarea.cpp.
References d, and QWidget::isVisible().
Referenced by EditorPage::addPluralForm(), EditorPage::EditorPage(), QCompleterPrivate::init(), QHeaderView::initialize(), KAsteroidsView::KAsteroidsView(), MessageEditor::MessageEditor(), OublietteView::OublietteView(), QCalendarView::QCalendarView(), qdesigner_internal::QtGradientStopsWidget::QtGradientStopsWidget(), and QComboBoxPrivateContainer::setItemView().
00551 { 00552 Q_D(QAbstractScrollArea); 00553 d->hbarpolicy = policy; 00554 if (isVisible()) 00555 d->layoutChildren(); 00556 }
Here is the call graph for this function:

| QScrollBar * QAbstractScrollArea::horizontalScrollBar | ( | ) | const |
Returns the horizontal scroll bar.
Definition at line 563 of file qabstractscrollarea.cpp.
References d.
Referenced by QGraphicsView::centerOn(), QTableView::columnCountChanged(), QAbstractItemView::doAutoScroll(), QGraphicsView::ensureVisible(), qdesigner_internal::QtGradientStopsWidgetPrivate::ensureVisible(), qdesigner_internal::QtGradientStopsWidgetPrivate::fromViewport(), QListView::horizontalOffset(), PieView::horizontalOffset(), QAbstractItemView::horizontalScrollbarValueChanged(), PieView::indexAt(), qdesigner_internal::QtGradientStopsWidget::minimumSizeHint(), SvgWindow::mouseMoveEvent(), PreviewView::mouseMoveEvent(), QGraphicsView::mouseMoveEvent(), PreviewView::mousePressEvent(), SvgWindow::mousePressEvent(), QTreeView::moveCursor(), PreviewView::paintEvent(), PieView::paintEvent(), qdesigner_internal::QtGradientStopsWidget::paintEvent(), PieView::PieView(), PreviewView::PreviewView(), qdesigner_internal::QtGradientStopsWidget::QtGradientStopsWidget(), QAccessibleTextEdit::rect(), PreviewView::resizeEvent(), ImageViewer::scaleImage(), QListView::scrollContentsBy(), QTableView::scrollContentsBy(), QTreeView::scrollContentsBy(), QListView::scrollTo(), QTableView::scrollTo(), PieView::scrollTo(), QTreeView::scrollTo(), OublietteView::scrollToCharacter(), qdesigner_internal::ObjectInspector::setFormWindow(), PieView::setSelection(), qdesigner_internal::QtGradientStopsWidget::setZoom(), QCompleterPrivate::showPopup(), QComboBox::showPopup(), qdesigner_internal::QtGradientStopsWidget::sizeHint(), qdesigner_internal::QtGradientStopsWidgetPrivate::toViewport(), QListView::updateGeometries(), PieView::updateGeometries(), QTreeView::updateGeometries(), QTableView::updateGeometries(), View::View(), and PieView::visualRect().
00564 { 00565 Q_D(const QAbstractScrollArea); 00566 return d->hbar; 00567 }
| void QAbstractScrollArea::setHorizontalScrollBar | ( | QScrollBar * | scrollBar | ) |
QAbstractScrollArea already provides horizontal and vertical scroll bars by default. You can call this function to replace the default horizontal scroll bar with your own custom scroll bar.
Definition at line 582 of file qabstractscrollarea.cpp.
References d, Qt::Horizontal, and qWarning().
00583 { 00584 Q_D(QAbstractScrollArea); 00585 if (!scrollBar) { 00586 qWarning("QAbstractScrollArea::setHorizontalScrollBar: Cannot set a null scroll bar"); 00587 return; 00588 } 00589 00590 d->replaceScrollBar(scrollBar, Qt::Horizontal); 00591 }
Here is the call graph for this function:

| QWidget * QAbstractScrollArea::cornerWidget | ( | ) | const |
By default, no corner widget is present.
Definition at line 600 of file qabstractscrollarea.cpp.
References d.
00601 { 00602 Q_D(const QAbstractScrollArea); 00603 return d->cornerWidget; 00604 }
| void QAbstractScrollArea::setCornerWidget | ( | QWidget * | widget | ) |
You will probably also want to set at least one of the scroll bar modes to AlwaysOn.
Passing 0 shows no widget in the corner.
Any previous corner widget is hidden.
You may call setCornerWidget() with the same widget at different times.
All widgets set here will be deleted by the scroll area when it is destroyed unless you separately reparent the widget after setting some other corner widget (or 0).
Any newly set widget should have no current parent.
By default, no corner widget is present.
Definition at line 632 of file qabstractscrollarea.cpp.
References d, QWidget::parentWidget(), QWidget::setParent(), and QWidget::show().
00633 { 00634 Q_D(QAbstractScrollArea); 00635 QWidget* oldWidget = d->cornerWidget; 00636 if (oldWidget != widget) { 00637 if (oldWidget) 00638 oldWidget->hide(); 00639 d->cornerWidget = widget; 00640 00641 if (widget && widget->parentWidget() != this) 00642 widget->setParent(this); 00643 00644 d->layoutChildren(); 00645 if (widget) 00646 widget->show(); 00647 } else { 00648 d->cornerWidget = widget; 00649 d->layoutChildren(); 00650 } 00651 }
Here is the call graph for this function:

| void QAbstractScrollArea::addScrollBarWidget | ( | QWidget * | widget, | |
| Qt::Alignment | alignment | |||
| ) |
AlwaysOn.alignment must be one of Qt::Alignleft and Qt::AlignRight, which maps to the horizontal scroll bar, or Qt::AlignTop and Qt::AlignBottom, which maps to the vertical scroll bar.
A scroll bar widget can be removed by either re-parenting the widget or deleting it. It's also possible to hide a widget with QWidget::hide()
The scroll bar widget will be resized to fit the scroll bar geometry for the current style. The following describes the case for scroll bar widgets on the horizontal scroll bar:
The height of the widget will be set to match the height of the scroll bar. To control the width of the widget, use QWidget::setMinimumWidth and QWidget::setMaximumWidth, or implement QWidget::sizeHint() and set a horizontal size policy. If you want a square widget, call QStyle::pixelMetric(QStyle::PM_ScrollBarExtent) and set the width to this value.
Definition at line 685 of file qabstractscrollarea.cpp.
References Qt::AlignBottom, Qt::AlignLeft, Qt::AlignRight, d, Qt::Horizontal, QWidget::isHidden(), QAbstractScrollAreaScrollBarContainer::LogicalLeft, QAbstractScrollAreaScrollBarContainer::LogicalRight, QWidget::show(), and Qt::Vertical.
00686 { 00687 Q_D(QAbstractScrollArea); 00688 00689 if (widget == 0) 00690 return; 00691 00692 const Qt::Orientation scrollBarOrientation 00693 = ((alignment & Qt::AlignLeft) || (alignment & Qt::AlignRight)) ? Qt::Horizontal : Qt::Vertical; 00694 const QAbstractScrollAreaScrollBarContainer::LogicalPosition position 00695 = ((alignment & Qt::AlignRight) || (alignment & Qt::AlignBottom)) 00696 ? QAbstractScrollAreaScrollBarContainer::LogicalRight : QAbstractScrollAreaScrollBarContainer::LogicalLeft; 00697 d->scrollBarContainers[scrollBarOrientation]->addWidget(widget, position); 00698 d->layoutChildren(); 00699 if (isHidden() == false) 00700 widget->show(); 00701 }
Here is the call graph for this function:

| QWidgetList QAbstractScrollArea::scrollBarWidgets | ( | Qt::Alignment | alignment | ) |
Definition at line 710 of file qabstractscrollarea.cpp.
References Qt::AlignBottom, Qt::AlignLeft, Qt::AlignRight, Qt::AlignTop, d, Qt::Horizontal, QAbstractScrollAreaScrollBarContainer::LogicalLeft, QAbstractScrollAreaScrollBarContainer::LogicalRight, and Qt::Vertical.
00711 { 00712 Q_D(QAbstractScrollArea); 00713 00714 QWidgetList list; 00715 00716 if (alignment & Qt::AlignLeft) 00717 list += d->scrollBarContainers[Qt::Horizontal]->widgets(QAbstractScrollAreaScrollBarContainer::LogicalLeft); 00718 if (alignment & Qt::AlignRight) 00719 list += d->scrollBarContainers[Qt::Horizontal]->widgets(QAbstractScrollAreaScrollBarContainer::LogicalRight); 00720 if (alignment & Qt::AlignTop) 00721 list += d->scrollBarContainers[Qt::Vertical]->widgets(QAbstractScrollAreaScrollBarContainer::LogicalLeft); 00722 if (alignment & Qt::AlignBottom) 00723 list += d->scrollBarContainers[Qt::Vertical]->widgets(QAbstractScrollAreaScrollBarContainer::LogicalRight); 00724 00725 return list; 00726 }
| QWidget * QAbstractScrollArea::viewport | ( | ) | const |
Returns the viewport widget.
Use the QScrollArea::widget() function to retrieve the contents of the viewport widget.
Definition at line 450 of file qabstractscrollarea.cpp.
References d.
Referenced by QGraphicsView::centerOn(), QAccessibleTextEdit::childAt(), QTreeView::collapse(), QTreeView::columnCountChanged(), QGraphicsView::contextMenuEvent(), TabbedBrowser::createHelpWindow(), PieView::dataChanged(), QGraphicsView::drawItems(), QGraphicsView::ensureVisible(), qdesigner_internal::QtGradientStopsWidgetPrivate::ensureVisible(), QGraphicsView::fitInView(), qdesigner_internal::QtGradientStopsWidget::focusInEvent(), qdesigner_internal::QPropertyEditor::focusInEvent(), qdesigner_internal::QtGradientStopsWidget::focusOutEvent(), qdesigner_internal::QtGradientStopsWidgetPrivate::fromViewport(), QTreeView::indexRowSizeHint(), PieView::itemRect(), KAsteroidsView::KAsteroidsView(), QTreeView::mouseDoubleClickEvent(), QGraphicsView::mouseDoubleClickEvent(), qdesigner_internal::QtGradientStopsWidget::mouseDoubleClickEvent(), qdesigner_internal::QtGradientStopsWidget::mouseMoveEvent(), QGraphicsView::mouseMoveEvent(), QGraphicsView::mousePressEvent(), QTreeView::mousePressEvent(), qdesigner_internal::QtGradientStopsWidget::mousePressEvent(), PieView::mouseReleaseEvent(), QGraphicsView::mouseReleaseEvent(), QTreeView::moveCursor(), PieView::moveCursor(), QTreeView::paintEvent(), PreviewView::paintEvent(), PieView::paintEvent(), qdesigner_internal::QtGradientStopsWidget::paintEvent(), QGraphicsView::paintEvent(), PreviewView::PreviewView(), PrintPreview::PrintPreview(), qdesigner_internal::QtGradientStopsWidget::QtGradientStopsWidget(), QAccessibleTextEdit::rect(), QGraphicsView::render(), QGraphicsView::resetCachedContent(), QComboBoxListView::resizeEvent(), MessageEditor::resizeEvent(), PreviewView::resizeEvent(), PieView::scrollContentsBy(), scrollContentsBy(), QGraphicsView::scrollContentsBy(), PieView::scrollTo(), QGraphicsView::setBackgroundBrush(), QGraphicsItem::setCursor(), SpreadSheetItem::setData(), QGraphicsView::setDragMode(), QGraphicsView::setForegroundBrush(), QAbstractItemView::setIndexWidget(), QComboBoxPrivateContainer::setItemView(), QGraphicsView::setMatrix(), QGraphicsView::setRenderHint(), QGraphicsView::setRenderHints(), QTableView::setRootIndex(), QFileDialogPrivate::setupTreeView(), setupViewport(), qdesigner_internal::QtGradientStopsWidget::setZoom(), QDBusViewer::showContextMenu(), HelpDialog::showIndexItemMenu(), HelpDialog::showListItemMenu(), MainWindow::showSearchLink(), HelpDialog::showTreeItemMenu(), qdesigner_internal::QtGradientStopsWidgetPrivate::slotCurrentStopChanged(), qdesigner_internal::ObjectInspector::slotPopupContextMenu(), qdesigner_internal::QtGradientStopsWidgetPrivate::slotStopAdded(), qdesigner_internal::QtGradientStopsWidgetPrivate::slotStopChanged(), qdesigner_internal::QtGradientStopsWidgetPrivate::slotStopMoved(), qdesigner_internal::QtGradientStopsWidgetPrivate::slotStopRemoved(), qdesigner_internal::QtGradientStopsWidgetPrivate::slotStopSelected(), qdesigner_internal::QtGradientStopsWidgetPrivate::toViewport(), QListView::updateGeometries(), PieView::updateGeometries(), PreviewView::updateLayout(), QGraphicsView::updateScene(), QGraphicsView::wheelEvent(), PreviewView::zoomIn(), and PreviewView::zoomOut().
00451 { 00452 Q_D(const QAbstractScrollArea); 00453 return d->viewport; 00454 }
| void QAbstractScrollArea::setViewport | ( | QWidget * | widget | ) |
Definition at line 423 of file qabstractscrollarea.cpp.
References d, QMetaObject::invokeMethod(), QWidget::isVisible(), and Q_ARG.
Referenced by QGraphicsView::QGraphicsView(), and View::toggleOpenGL().
00424 { 00425 Q_D(QAbstractScrollArea); 00426 if (widget != d->viewport) { 00427 QWidget *oldViewport = d->viewport; 00428 if (!widget) 00429 widget = new QWidget; 00430 d->viewport = widget; 00431 d->viewport->setParent(this); 00432 d->viewport->setFocusProxy(this); 00433 d->viewport->installEventFilter(d->viewportFilter); 00434 d->layoutChildren(); 00435 if (isVisible()) 00436 d->viewport->show(); 00437 QMetaObject::invokeMethod(this, "setupViewport", Q_ARG(QWidget *, widget)); 00438 delete oldViewport; 00439 } 00440 }
Here is the call graph for this function:

| QSize QAbstractScrollArea::maximumViewportSize | ( | ) | const |
Returns the size of the viewport as if the scroll bars had no valid scrolling range.
Definition at line 462 of file qabstractscrollarea.cpp.
References d, QSize::rheight(), QSize::rwidth(), Qt::ScrollBarAlwaysOn, and QWidget::size().
Referenced by MainWindow::setPixmap(), QListView::updateGeometries(), and QTableView::updateGeometries().
00463 { 00464 Q_D(const QAbstractScrollArea); 00465 int hsbExt = d->hbar->sizeHint().height(); 00466 int vsbExt = d->vbar->sizeHint().width(); 00467 00468 int f = 2 * d->frameWidth; 00469 QSize max = size() - QSize(f + d->left + d->right, f + d->top + d->bottom); 00470 if (d->vbarpolicy == Qt::ScrollBarAlwaysOn) 00471 max.rwidth() -= vsbExt; 00472 if (d->hbarpolicy == Qt::ScrollBarAlwaysOn) 00473 max.rheight() -= hsbExt; 00474 return max; 00475 }
Here is the call graph for this function:

| QSize QAbstractScrollArea::minimumSizeHint | ( | ) | const [virtual] |
Reimplemented from QWidget.
Definition at line 1126 of file qabstractscrollarea.cpp.
References d, Qt::Horizontal, and Qt::Vertical.
01127 { 01128 Q_D(const QAbstractScrollArea); 01129 int hsbExt = d->hbar->sizeHint().height(); 01130 int vsbExt = d->vbar->sizeHint().width(); 01131 int extra = 2 * d->frameWidth; 01132 return QSize(d->scrollBarContainers[Qt::Horizontal]->sizeHint().width() + vsbExt + extra, 01133 d->scrollBarContainers[Qt::Vertical]->sizeHint().height() + hsbExt + extra); 01134 }
| QSize QAbstractScrollArea::sizeHint | ( | ) | const [virtual] |
Reimplemented from QFrame.
Definition at line 1139 of file qabstractscrollarea.cpp.
References d, QWidget::fontMetrics(), h, QWidget::height(), and qMax().
Referenced by QGraphicsView::sizeHint(), QTableView::sizeHintForColumn(), and QTableView::sizeHintForRow().
01140 { 01141 return QSize(256, 192); 01142 #if 0 01143 Q_D(const QAbstractScrollArea); 01144 int h = qMax(10, fontMetrics().height()); 01145 int f = 2 * d->frameWidth; 01146 return QSize((6 * h) + f, (4 * h) + f); 01147 #endif 01148 }
Here is the call graph for this function:

| void QAbstractScrollArea::setupViewport | ( | QWidget * | viewport | ) | [protected, slot] |
This slot is called by QAbstractScrollArea after setViewport(viewport) has been called. Reimplement this function in a subclass of QAbstractScrollArea to initialize the new viewport before it is used.
Definition at line 1158 of file qabstractscrollarea.cpp.
References viewport().
01159 { 01160 Q_UNUSED(viewport); 01161 }
| void QAbstractScrollArea::setViewportMargins | ( | int | left, | |
| int | top, | |||
| int | right, | |||
| int | bottom | |||
| ) | [protected] |
Sets the margins around the scrolling area to left, top, right and bottom. This is useful for applications such as spreadsheets with "locked" rows and columns. The marginal space is is left blank; put widgets in the unused area.
By default all margins are zero.
Definition at line 737 of file qabstractscrollarea.cpp.
References d.
Referenced by QTreeView::updateGeometries(), and QTableView::updateGeometries().
00738 { 00739 Q_D(QAbstractScrollArea); 00740 d->left = left; 00741 d->top = top; 00742 d->right = right; 00743 d->bottom = bottom; 00744 d->layoutChildren(); 00745 }
| bool QAbstractScrollArea::event | ( | QEvent * | event | ) | [protected, virtual] |
This is the main event handler for the QAbstractScrollArea widget (not the scrolling area viewport()). The specified event is a general event object that may need to be cast to the appropriate class depending on its type.
Reimplemented from QFrame.
Definition at line 759 of file qabstractscrollarea.cpp.
References QWidget::acceptDrops(), QEvent::AcceptDropsChange, QEvent::ContextMenu, d, QEvent::DragEnter, QEvent::DragLeave, QEvent::DragMove, QStyle::drawPrimitive(), QEvent::Drop, QFrame::event(), QWidget::hasMouseTracking(), QContextMenuEvent::Keyboard, QEvent::MouseButtonDblClick, QEvent::MouseButtonPress, QEvent::MouseButtonRelease, QEvent::MouseMove, QEvent::MouseTrackingChange, p, QEvent::Paint, QFrame::paintEvent(), QStyle::PE_PanelScrollAreaCorner, QEvent::Resize, QWidget::style(), QEvent::StyleChange, QEvent::type(), and QEvent::Wheel.
Referenced by QAbstractItemView::event(), QGraphicsView::event(), QScrollArea::event(), QTextEdit::event(), and viewportEvent().
00760 { 00761 Q_D(QAbstractScrollArea); 00762 switch (e->type()) { 00763 case QEvent::AcceptDropsChange: 00764 d->viewport->setAcceptDrops(acceptDrops()); 00765 break; 00766 case QEvent::MouseTrackingChange: 00767 d->viewport->setMouseTracking(hasMouseTracking()); 00768 break; 00769 case QEvent::Resize: 00770 d->layoutChildren(); 00771 break; 00772 case QEvent::Paint: 00773 if (d->cornerPaintingRect.isValid()) { 00774 QStyleOption option; 00775 option.rect = d->cornerPaintingRect; 00776 QPainter p(this); 00777 style()->drawPrimitive(QStyle::PE_PanelScrollAreaCorner, &option, &p, this); 00778 } 00779 #ifdef Q_WS_MAC 00780 if (d->reverseCornerPaintingRect.isValid()) { 00781 QStyleOption option; 00782 option.rect = d->reverseCornerPaintingRect; 00783 QPainter p(this); 00784 style()->drawPrimitive(QStyle::PE_PanelScrollAreaCorner, &option, &p, this); 00785 } 00786 #endif 00787 QFrame::paintEvent((QPaintEvent*)e); 00788 break; 00789 case QEvent::ContextMenu: 00790 if (static_cast<QContextMenuEvent *>(e)->reason() == QContextMenuEvent::Keyboard) 00791 return QFrame::event(e); 00792 e->ignore(); 00793 break; 00794 case QEvent::MouseButtonPress: 00795 case QEvent::MouseButtonRelease: 00796 case QEvent::MouseButtonDblClick: 00797 case QEvent::MouseMove: 00798 case QEvent::Wheel: 00799 #ifndef QT_NO_DRAGANDDROP 00800 case QEvent::Drop: 00801 case QEvent::DragEnter: 00802 case QEvent::DragMove: 00803 case QEvent::DragLeave: 00804 #endif 00805 return false; 00806 case QEvent::StyleChange: 00807 d->layoutChildren(); 00808 // fall through 00809 default: 00810 return QFrame::event(e); 00811 } 00812 return true; 00813 }
Here is the call graph for this function:

| bool QAbstractScrollArea::viewportEvent | ( | QEvent * | event | ) | [protected, virtual] |
The main event handler for the scrolling area (the viewport() widget). It handles the event specified, and can be called by subclasses to provide reasonable default behavior.
Returns true to indicate to the event system that the event has been handled, and needs no further processing; otherwise returns false to indicate that the event should be propagated further.
You can reimplement this function in a subclass, but we recommend using one of the specialized event handlers instead.
Specialised handlers for viewport events are: paintEvent(), mousePressEvent(), mouseReleaseEvent(), mouseDoubleClickEvent(), mouseMoveEvent(), wheelEvent(), dragEnterEvent(), dragMoveEvent(), dragLeaveEvent(), dropEvent(), contextMenuEvent(), and resizeEvent().
Definition at line 835 of file qabstractscrollarea.cpp.
References QEvent::ContextMenu, QEvent::DragEnter, QEvent::DragLeave, QEvent::DragMove, QEvent::Drop, event(), QFrame::event(), QEvent::LayoutRequest, QEvent::MouseButtonDblClick, QEvent::MouseButtonPress, QEvent::MouseButtonRelease, QEvent::MouseMove, QEvent::Paint, QEvent::Resize, QEvent::type(), and QEvent::Wheel.
Referenced by QAbstractItemView::viewportEvent(), and QGraphicsView::viewportEvent().
00836 { 00837 switch (e->type()) { 00838 case QEvent::Resize: 00839 case QEvent::Paint: 00840 case QEvent::MouseButtonPress: 00841 case QEvent::MouseButtonRelease: 00842 case QEvent::MouseButtonDblClick: 00843 case QEvent::MouseMove: 00844 case QEvent::ContextMenu: 00845 #ifndef QT_NO_WHEELEVENT 00846 case QEvent::Wheel: 00847 #endif 00848 #ifndef QT_NO_DRAGANDDROP 00849 case QEvent::Drop: 00850 case QEvent::DragEnter: 00851 case QEvent::DragMove: 00852 case QEvent::DragLeave: 00853 #endif 00854 return QFrame::event(e); 00855 case QEvent::LayoutRequest: 00856 return event(e); 00857 default: 00858 break; 00859 } 00860 return false; // let the viewport widget handle the event 00861 }
Here is the call graph for this function:

| void QAbstractScrollArea::resizeEvent | ( | QResizeEvent * | event | ) | [protected, virtual] |
This event handler can be reimplemented in a subclass to receive resize events (passed in event), for the viewport() widget.
When resizeEvent() is called, the viewport already has its new geometry: Its new size is accessible through the QResizeEvent::size() function, and the old size through QResizeEvent::oldSize().
Reimplemented from QWidget.
Definition at line 876 of file qabstractscrollarea.cpp.
Referenced by QGraphicsView::resizeEvent(), and QAbstractItemView::resizeEvent().
| void QAbstractScrollArea::paintEvent | ( | QPaintEvent * | event | ) | [protected, virtual] |
This event handler can be reimplemented in a subclass to receive paint events (passed in event), for the viewport() widget.
Note: If you open a painter, make sure to open it on the viewport().
Reimplemented from QFrame.
Definition at line 891 of file qabstractscrollarea.cpp.
Referenced by QGraphicsView::paintEvent().
| void QAbstractScrollArea::mousePressEvent | ( | QMouseEvent * | e | ) | [protected, virtual] |
This event handler can be reimplemented in a subclass to receive mouse press events for the viewport() widget. The event is passed in e.
Reimplemented from QWidget.
Definition at line 902 of file qabstractscrollarea.cpp.
References QEvent::ignore().
00903 { 00904 e->ignore(); 00905 }
Here is the call graph for this function:

| void QAbstractScrollArea::mouseReleaseEvent | ( | QMouseEvent * | e | ) | [protected, virtual] |
This event handler can be reimplemented in a subclass to receive mouse release events for the viewport() widget. The event is passed in e.
Reimplemented from QWidget.
Definition at line 914 of file qabstractscrollarea.cpp.
References QEvent::ignore().
00915 { 00916 e->ignore(); 00917 }
Here is the call graph for this function:

| void QAbstractScrollArea::mouseDoubleClickEvent | ( | QMouseEvent * | e | ) | [protected, virtual] |
This event handler can be reimplemented in a subclass to receive mouse double click events for the viewport() widget. The event is passed in e.
Reimplemented from QWidget.
Definition at line 926 of file qabstractscrollarea.cpp.
References QEvent::ignore().
00927 { 00928 e->ignore(); 00929 }
Here is the call graph for this function:

| void QAbstractScrollArea::mouseMoveEvent | ( | QMouseEvent * | e | ) | [protected, virtual] |
This event handler can be reimplemented in a subclass to receive mouse move events for the viewport() widget. The event is passed in e.
Reimplemented from QWidget.
Definition at line 938 of file qabstractscrollarea.cpp.
References QEvent::ignore().
00939 { 00940 e->ignore(); 00941 }
Here is the call graph for this function:

| void QAbstractScrollArea::wheelEvent | ( | QWheelEvent * | e | ) | [protected, virtual] |
This event handler can be reimplemented in a subclass to receive wheel events for the viewport() widget. The event is passed in e.
Reimplemented from QWidget.
Definition at line 951 of file qabstractscrollarea.cpp.
References d, Qt::Horizontal, and QCoreApplication::sendEvent().
Referenced by QTextEdit::wheelEvent(), and QGraphicsView::wheelEvent().
00952 { 00953 Q_D(QAbstractScrollArea); 00954 if (static_cast<QWheelEvent*>(e)->orientation() == Qt::Horizontal) 00955 QApplication::sendEvent(d->hbar, e); 00956 else 00957 QApplication::sendEvent(d->vbar, e); 00958 }
Here is the call graph for this function:

| void QAbstractScrollArea::contextMenuEvent | ( | QContextMenuEvent * | e | ) | [protected, virtual] |
This event handler can be reimplemented in a subclass to receive context menu events for the viewport() widget. The event is passed in e.
Reimplemented from QWidget.
Definition at line 968 of file qabstractscrollarea.cpp.
References QEvent::ignore().
00969 { 00970 e->ignore(); 00971 }
Here is the call graph for this function:

| void QAbstractScrollArea::dragEnterEvent | ( | QDragEnterEvent * | event | ) | [protected, virtual] |
This event handler can be reimplemented in a subclass to receive drag enter events (passed in event), for the viewport() widget.
Reimplemented from QWidget.
Definition at line 1020 of file qabstractscrollarea.cpp.
| void QAbstractScrollArea::dragMoveEvent | ( | QDragMoveEvent * | event | ) | [protected, virtual] |
This event handler can be reimplemented in a subclass to receive drag move events (passed in event), for the viewport() widget.
Reimplemented from QWidget.
Definition at line 1032 of file qabstractscrollarea.cpp.
| void QAbstractScrollArea::dragLeaveEvent | ( | QDragLeaveEvent * | event | ) | [protected, virtual] |
This event handler can be reimplemented in a subclass to receive drag leave events (passed in event), for the viewport() widget.
Reimplemented from QWidget.
Definition at line 1044 of file qabstractscrollarea.cpp.
| void QAbstractScrollArea::dropEvent | ( | QDropEvent * | event | ) | [protected, virtual] |
This event handler can be reimplemented in a subclass to receive drop events (passed in event), for the viewport() widget.
Reimplemented from QWidget.
Definition at line 1056 of file qabstractscrollarea.cpp.
| void QAbstractScrollArea::keyPressEvent | ( | QKeyEvent * | e | ) | [protected, virtual] |
This function is called with key event e when key presses occur. It handles PageUp, PageDown, Up, Down, Left, and Right, and ignores all other key presses.
Reimplemented from QWidget.
Definition at line 978 of file qabstractscrollarea.cpp.
References QEvent::accept(), d, QEvent::ignore(), QKeyEvent::key(), Qt::Key_Down, Qt::Key_Left, Qt::Key_Right, Qt::Key_Up, QKeySequence::MoveToNextPage, QKeySequence::MoveToPreviousPage, QAbstractSlider::SliderPageStepAdd, QAbstractSlider::SliderPageStepSub, QAbstractSlider::SliderSingleStepAdd, and QAbstractSlider::SliderSingleStepSub.
Referenced by QGraphicsView::keyPressEvent(), and QTextEdit::keyPressEvent().
00979 { 00980 Q_D(QAbstractScrollArea); 00981 if (false){ 00982 #ifndef QT_NO_SHORTCUT 00983 } else if (e == QKeySequence::MoveToPreviousPage) { 00984 d->vbar->triggerAction(QScrollBar::SliderPageStepSub); 00985 } else if (e == QKeySequence::MoveToNextPage) { 00986 d->vbar->triggerAction(QScrollBar::SliderPageStepAdd); 00987 #endif 00988 } else { 00989 switch (e->key()) { 00990 case Qt::Key_Up: 00991 d->vbar->triggerAction(QScrollBar::SliderSingleStepSub); 00992 break; 00993 case Qt::Key_Down: 00994 d->vbar->triggerAction(QScrollBar::SliderSingleStepAdd); 00995 break; 00996 case Qt::Key_Left: 00997 d->hbar->triggerAction(QScrollBar::SliderSingleStepSub); 00998 break; 00999 case Qt::Key_Right: 01000 d->hbar->triggerAction(QScrollBar::SliderSingleStepAdd); 01001 break; 01002 default: 01003 e->ignore(); 01004 return; 01005 } 01006 } 01007 e->accept(); 01008 }
Here is the call graph for this function:

| void QAbstractScrollArea::scrollContentsBy | ( | int | dx, | |
| int | dy | |||
| ) | [protected, virtual] |
This virtual handler is called when the scroll bars are moved by dx, dy, and consequently the viewport's contents should be scrolled accordingly.
The default implementation simply calls update() on the entire viewport(), subclasses can reimplement this handler for optimization purposes, or - like QScrollArea - to move a contents widget. The parameters dx and dy are there for convenience, so that the class knows how much should be scrolled (useful e.g. when doing pixel-shifts). You may just as well ignore these values and scroll directly to the position the scroll bars indicate.
Calling this function in order to scroll programmatically is an error, use the scroll bars instead (e.g. by calling QScrollBar::setValue() directly).
Definition at line 1081 of file qabstractscrollarea.cpp.
References QWidget::update(), and viewport().
Here is the call graph for this function:

| QAbstractScrollArea::Q_PRIVATE_SLOT | ( | d_func() | , | |
| void | _q_hslide(int) | |||
| ) | [private] |
| void QAbstractScrollArea::_q_vslide | ( | int | ) | [private] |
1.5.1