QScrollView(3qt)

NAME
QScrollView - Scrolling area with on-demand scrollbars

#include <qscrollview.h>

Inherits QFrame.

Inherited by QCanvasView, QIconView, QListBox, QListView, QTable and QTextView.

  Public Members
QScrollView ( QWidget * parent=0, const char * name=0, WFlags f=0 )
~QScrollView ()
enum ResizePolicy { Default, Manual, AutoOne, AutoOneFit }
virtual void setResizePolicy ( ResizePolicy )
ResizePolicy resizePolicy () const
void removeChild ( QWidget * child )
virtual void addChild ( QWidget * child, int x=0, int y=0 )
virtual void moveChild ( QWidget * child, int x, int y )
int childX ( QWidget * child )
int childY ( QWidget * child )
bool childIsVisible ( QWidget * child ) (obsolete)
void showChild ( QWidget * child, bool yes=TRUE ) (obsolete)
enum ScrollBarMode { Auto, AlwaysOff, AlwaysOn }
ScrollBarMode vScrollBarMode () const
virtual void setVScrollBarMode ( ScrollBarMode )
ScrollBarMode hScrollBarMode () const
virtual void setHScrollBarMode ( ScrollBarMode )
QWidget* cornerWidget () const
virtual void setCornerWidget ( QWidget * )
QScrollBar* horizontalScrollBar () const
QScrollBar* verticalScrollBar () const
QWidget* viewport () const
QWidget* clipper () const
int visibleWidth () const
int visibleHeight () const
int contentsWidth () const
int contentsHeight () const
int contentsX () const
int contentsY () const
void updateContents ( int x, int y, int w, int h )
void updateContents ( const QRect & r )
void repaintContents ( int x, int y, int w, int h, bool erase=TRUE )
void repaintContents ( const QRect & r, bool erase=TRUE )
void contentsToViewport ( int x, int y, int & vx, int & vy )
void viewportToContents ( int vx, int vy, int & x, int & y )
QPoint contentsToViewport ( const QPoint & )
QPoint viewportToContents ( const QPoint & )
void enableClipper ( bool y )
void setStaticBackground ( bool y )
bool hasStaticBackground () const
QSize viewportSize ( int, int ) const
void setDragAutoScroll ( bool b )
bool dragAutoScroll () const

  Public Slots
virtual void resizeContents ( int w, int h )
void scrollBy ( int dx, int dy )
virtual void setContentsPos ( int x, int y )
void ensureVisible ( int x, int y )
void ensureVisible ( int x, int y, int xmargin, int ymargin )
void center ( int x, int y )
void center ( int x, int y, float xmargin, float ymargin )
void updateScrollBars ()

  Signals
void contentsMoving ( int x, int y )

  Protected Members
virtual bool eventFilter ( QObject *, QEvent * e )
virtual void contentsMousePressEvent ( QMouseEvent * )
virtual void contentsMouseReleaseEvent ( QMouseEvent * )
virtual void contentsMouseDoubleClickEvent ( QMouseEvent * )
virtual void contentsMouseMoveEvent ( QMouseEvent * )
virtual void contentsDragEnterEvent ( QDragEnterEvent * )
virtual void contentsDragMoveEvent ( QDragMoveEvent * )
virtual void contentsDragLeaveEvent ( QDragLeaveEvent * )
virtual void contentsDropEvent ( QDropEvent * )
virtual void contentsWheelEvent ( QWheelEvent * )
virtual void viewportPaintEvent ( QPaintEvent * )
virtual void viewportResizeEvent ( QResizeEvent * )
virtual void viewportMousePressEvent ( QMouseEvent * )
virtual void viewportMouseReleaseEvent ( QMouseEvent * )
virtual void viewportMouseDoubleClickEvent ( QMouseEvent * )
virtual void viewportMouseMoveEvent ( QMouseEvent * )
virtual void viewportDragEnterEvent ( QDragEnterEvent * )
virtual void viewportDragMoveEvent ( QDragMoveEvent * )
virtual void viewportDragLeaveEvent ( QDragLeaveEvent * )
virtual void viewportDropEvent ( QDropEvent * )
virtual void viewportWheelEvent ( QWheelEvent * )
virtual void drawContentsOffset ( QPainter *, int ox, int oy, int cx, int cy, int cw, int ch )
virtual void drawContents ( QPainter *, int cx, int cy, int cw, int ch )
virtual void setMargins ( int left, int top, int right, int bottom )
int leftMargin () const
int topMargin () const
int rightMargin () const
int bottomMargin () const
virtual void setHBarGeometry ( QScrollBar & hbar, int x, int y, int w, int h )
virtual void setVBarGeometry ( QScrollBar & vbar, int x, int y, int w, int h )

  Properties
Type | Name | READ | WRITE | Options
ResizePolicy | resizePolicy | resizePolicy | setResizePolicy
ScrollBarMode | vScrollBarMode | vScrollBarMode | setVScrollBarMode
ScrollBarMode | hScrollBarMode | hScrollBarMode | setHScrollBarMode
int | visibleWidth | visibleWidth
int | visibleHeight | visibleHeight
int | contentsWidth | contentsWidth
int | contentsHeight | contentsHeight
int | contentsX | contentsX
int | contentsY | contentsY
bool | dragAutoScroll | dragAutoScroll | setDragAutoScroll

DESCRIPTION
The QScrollView widget provides a scrolling area with on-demand scrollbars.

The QScrollView is a large canvas - potentially larger than the coordinate system normally supported by the underlying window system. This is important, as is is quite easy to go beyond such limitations (eg. many web pages are more than 32000 pixels high). Additionally, the QScrollView can have QWidgets positioned on it that scroll around with the drawn content. These subwidgets can also have positions outside the normal coordinate range (but they are still limited in size).

To provide content for the widget, inherit from QScrollView and reimplement drawContents(), and use resizeContents() to set the size of the viewed area. Use addChild() / moveChild() to position widgets on the view.

To use QScrollView effectively, it is important to understand its widget structure in the three styles of usage: a single large child widget, a large panning area with some widgets, a large panning area with many widgets.

One Big Widget

[Image Omitted]

The first, simplest usage of QScrollView depicted above is appropriate for scrolling areas which are never more than about 4000 pixels in either dimension (this is about the maximum reliable size on X11 servers). In this usage, you just make one large child in the QScrollView. The child should be a child of the viewport() of the scrollview, and be added with addChild():

    QScrollView* sv = new QScrollView(...);
    QVBox* big_box = new QVBox(sv->viewport());
    sv->addChild(big_box);

You may go on to add arbitrary child widgets to the single child in the scrollview, as you would with any widget:

    QLabel* child1 = new QLabel("CHILD", big_box);
    QLabel* child2 = new QLabel("CHILD", big_box);
    QLabel* child3 = new QLabel("CHILD", big_box);
    ...

Here, the QScrollView has 4 children - the viewport(), the verticalScrollBar(), the horizontalScrollBar(), and a small cornerWidget(). The viewport() has 1 child, the big QVBox. The QVBox has the three labels as child widgets. When the view is scrolled, the QVBox is moved, and its children move with it as child widgets normally do.

Very Big View, some Widgets

[Image Omitted]

The second usage of QScrollView depicted above is appropriate when few, if any, widgets are on a very large scrolling area that is potentially larger than 4000 pixels in either dimension. In this usage, you call resizeContents() to set the size of the area, and reimplement drawContents() to paint the contents. You may also add some widgets, by making them children of the viewport() and adding them with addChild() (this is the same as the process for the single large widget in the previous example):

    QScrollView* sv = new QScrollView(...);
    QLabel* child1 = new QLabel("CHILD", sv->viewport());
    sv->addChild(child1);
    QLabel* child2 = new QLabel("CHILD", sv->viewport());
    sv->addChild(child2);
    QLabel* child3 = new QLabel("CHILD", sv->viewport());
    sv->addChild(child3);

Here, the QScrollView has the same 4 children - the viewport(), the verticalScrollBar(), the horizontalScrollBar(), and a small cornerWidget(). The viewport() has the three labels as child widgets. When the view is scrolled, the scrollview moves the child widgets individually.

Very Big View, many Widgets

[Image Omitted]

The final usage of QScrollView depicted above is appropriate when many widgets are on a very large scrolling area that is potentially larger than 4000 pixels in either dimension. In this usage, you call resizeContents() to set the size of the area, and reimplement drawContents() to paint the contents. You then call enableClipper(TRUE) and add widgets, again by making them children of the viewport() and adding them with addChild():

    QScrollView* sv = new QScrollView(...);
    sv->enableClipper(TRUE);
    QLabel* child1 = new QLabel("CHILD", sv->viewport());
    sv->addChild(child1);
    QLabel* child2 = new QLabel("CHILD", sv->viewport());
    sv->addChild(child2);
    QLabel* child3 = new QLabel("CHILD", sv->viewport());
    sv->addChild(child3);

Here, the QScrollView has 4 children - the clipper() (not the viewport() this time), the verticalScrollBar(), the horizontalScrollBar(), and a small cornerWidget(). The clipper() has 1 child - the viewport(). The viewport() has the three labels as child widgets. When the view is scrolled, the viewport() is moved, and its children move with it as child widgets normally do.

Normally you will use the first or third method if you want any child widgets in the view.

Note that the widget you see in the scrolled area is the viewport() widget, not the QScrollView itself. So, to turn mouse tracking on for example, use viewport()->setMouseTracking(TRUE).

To enable drag-and-drop, you would setAcceptDrops(TRUE) on the QScrollView (since drag-and-drop events propagate to the parent), but to work out what logical position in the view, you would need to map the drop co-ordinate from being relative to the QScrollView to being relative to the contents - use the function viewportToContents() for this.

To handle mouse events on the scrolling area, subclass scrollview as you would subclass other widgets, but rather than overriding mousePressEvent(), reimplement viewportMousePressEvent() instead (if you reimplement mousePressEvent() you'll only get called when part of the QScrollView is clicked - and the only such part is the "corner" (if you don't set a cornerWidget()) and the frame, everything else being covered up by the viewport, clipper, or scrollbars.

When you construct a QScrollView, some of the widget flags apply to the viewport(), instead of being sent to the QWidget constructor for the QScrollView. This applies to WResizeNoErase, WNorthWestGravity, WRepaintNoErase and WPaintClever. See Qt::WidgetFlags for documentation about these flags. Here are some examples:

An image manipulation widget would use WResizeNoErase|WNorthWestGravity, because the widget draws all pixels itself and when the size increases, it only needs a paint event for the new part, since the old part remains unchanged.

A word processing widget might use WResizeNoErase and repaint itself line by line to get a less flickery resizing. If the widget is in a mode where no text justification can take place, it might use WNorthWestGravity too, so that it would only get a repaint for the newly visible parts.

A scrolling game widget where the background scrolls as the characters move might use WRepaintNoErase (in addition to WNorthWestGravity and WResizeNoErase) so that the window system background does not flash in and out during scrolling.

Warning: WResizeNoErase is currently set by default, i.e. you always have to clear the background manually in scrollview subclasses. This will change in a future version of Qt, and we recommend specifying the flag explicitly.

[Image Omitted]

[Image Omitted]

Examples: scrollview/scrollview.cpp

  Member Type Documentation

QScrollView::ResizePolicy
This enum type is used to control QScrollView's reaction to resize events. There are four possible settings:

Default - QScrollView selects one of the other settings automatically when it has to. In this version of Qt, QScrollView changes to Manual if you resize the contents with resizeContents(), and to AutoOne if a child is added.

Manual - the view stays the size set by resizeContents().

AutoOne - if there is only child widget, the view stays the size of that widget. Otherwise, the behaviour is undefined.

AutoOneFit - if there is only one child widget the view stays the size of that widget's sizeHint(). If the scrollview is resized bigger than the child's sizeHint(), the child will be resized to fit. If there is more than one child, the behaviour is undefined.

QScrollView::ScrollBarMode
This enum type describes the various modes of QScrollView's scroll bars. The defined modes are:

Auto - QScrollView shows a scrollbar when the content is too tall to fit and not else. This is the default.

AlwaysOff - QScrollView never shows a scrollbar.

AlwaysOn - QScrollView always shows a scrollbar.

(The modes for the horizontal and vertical scroll bars are independent.).

Examples: scrollview/scrollview.cpp

MEMBER FUNCTION DOCUMENTATION

QScrollView::QScrollView ( QWidget * parent=0, const char * name=0, WFlags f=0 )
Constructs a QScrollView with a parent, a name and widget flags f.

The widget flags WNorthWestGravity, WRepaintNoErase and WPaintClever are propagated to the viewport() widget. The other widget flags are propagated to the parent constructor as usual.

QScrollView::~QScrollView ()
Destructs the QScrollView. Any children added with addChild() will be destructed.

void QScrollView::addChild ( QWidget * child, int x=0, int y=0 ) [virtual]
Inserts child into the scrolled area positioned at (x, y). The position defaults to (0,0). If the child is already in the view, it is just moved.

You may want to call enableClipper(TRUE) if you add a large number of widgets.

Examples: scrollview/scrollview.cpp

int QScrollView::bottomMargin () const [protected]
Returns the current bottom margin.

See also setMargins().

void QScrollView::center ( int x, int y ) [slot]
Scrolls the content so that the point (x,y) is in the center of visible area.

void QScrollView::center ( int x, int y, float xmargin, float ymargin ) [slot]
Scrolls the content so that the point (x,y) is visible, with the given margins (as fractions of visible area).

eg.

Margin 0.0 allows (x,y) to be on edge of visible area.

Margin 0.5 ensures (x,y) is in middle 50% of visible area.

Margin 1.0 ensures (x,y) is in the center of the visible area.

bool QScrollView::childIsVisible ( QWidget * child )
This function is obsolete. It is provided to keep old source working, and will probably be removed in a future version of Qt. We strongly advise against using it in new code.

Returns TRUE if child is visible. This is equivalent to child->isVisible().

int QScrollView::childX ( QWidget * child )
Returns the X position of the given child widget. Use this rather than QWidget::x() for widgets added to the view.

int QScrollView::childY ( QWidget * child )
Returns the Y position of the given child widget. Use this rather than QWidget::y() for widgets added to the view.

QWidget* QScrollView::clipper () const
Returns the clipper widget. Contents in the scrollview is ultimately clipped to be inside the clipper widget.

You should not need to access this.

See also visibleWidth() and visibleHeight().

void QScrollView::contentsDragEnterEvent ( QDragEnterEvent * ) [virtual protected]
This event handler is called whenever the QScrollView receives a dragEnterEvent() - the drag position is translated to be a point on the contents.

void QScrollView::contentsDragLeaveEvent ( QDragLeaveEvent * ) [virtual protected]
This event handler is called whenever the QScrollView receives a dragLeaveEvent() - the drag position is translated to be a point on the contents.

void QScrollView::contentsDragMoveEvent ( QDragMoveEvent * ) [virtual protected]
This event handler is called whenever the QScrollView receives a dragMoveEvent() - the drag position is translated to be a point on the contents.

void QScrollView::contentsDropEvent ( QDropEvent * ) [virtual protected]
This event handler is called whenever the QScrollView receives a dropEvent() - the drop position is translated to be a point on the contents.

int QScrollView::contentsHeight () const
Returns the height of the contents area.

void QScrollView::contentsMouseDoubleClickEvent ( QMouseEvent * ) [virtual protected]
This event handler is called whenever the QScrollView receives a mouseDoubleClickEvent() - the click position is translated to be a point on the contents.

Reimplemented in QTable and QListView.

void QScrollView::contentsMouseMoveEvent ( QMouseEvent * ) [virtual protected]
This event handler is called whenever the QScrollView receives a mouseMoveEvent() - the mouse position is translated to be a point on the contents.

Reimplemented in QListView and QTable.

void QScrollView::contentsMousePressEvent ( QMouseEvent * ) [virtual protected]
This event handler is called whenever the QScrollView receives a mousePressEvent() - the press position is translated to be a point on the contents.

Reimplemented in QListView and QTable.

void QScrollView::contentsMouseReleaseEvent ( QMouseEvent * ) [virtual protected]
This event handler is called whenever the QScrollView receives a mouseReleaseEvent() - the release position is translated to be a point on the contents.

Reimplemented in QListView and QTable.

void QScrollView::contentsMoving ( int x, int y ) [signal]
This signal is emitted just before the contents is moved to the given position.

See also contentsX() and contentsY().

QPoint QScrollView::contentsToViewport ( const QPoint & p )
Returns the point p translated to a point on the viewport() widget.

void QScrollView::contentsToViewport ( int x, int y, int & vx, int & vy )
Translates a point (x, y) in the contents to a point (vx, vy) on the viewport() widget.

void QScrollView::contentsWheelEvent ( QWheelEvent * e ) [virtual protected]
This event handler is called whenever the QScrollView receives a wheelEvent() - the mouse position is translated to be a point on the contents.

int QScrollView::contentsWidth () const
Returns the width of the contents area.

int QScrollView::contentsX () const
Returns the X coordinate of the contents which is at the left edge of the viewport.

int QScrollView::contentsY () const
Returns the Y coordinate of the contents which is at the top edge of the viewport.

QWidget* QScrollView::cornerWidget () const
Returns the widget in the corner between the two scrollbars.

By default, no corner widget is present.

Examples: scrollview/scrollview.cpp

bool QScrollView::dragAutoScroll () const
Returns TRUE if autoscrolling in drag move events is enabled, else FALSE.

See also setDragAutoScroll().

void QScrollView::drawContents ( QPainter * p, int clipx, int clipy, int clipw, int cliph ) [virtual protected]
Reimplement this method if you are viewing a drawing area rather than a widget.

The function should draw the rectangle (clipx, clipy, clipw, cliph ) of the contents, using painter p. The clip rectangle is in the scroll views's coordinates.

For example:

  {
    // Fill a 40000 by 50000 rectangle at (100000,150000)
    // Calculate the coordinates...
    int x1 = 100000, y1 = 150000;
    int x2 = x1+40000-1, y2 = y1+50000-1;
    // Clip the coordinates so X/Windows will not have problems...
    if (x1 < clipx) x1=clipx;
    if (y1 < clipy) y1=clipy;
    if (x2 > clipx+clipw-1) x2=clipx+clipw-1;
    if (y2 > clipy+cliph-1) y2=clipy+cliph-1;
    // Paint using the small coordinates...
    if ( x2 >= x1 && y2 >= y1 )
        p->fillRect(x1, y1, x2-x1+1, y2-y1+1, red);
  }

The clip rectangle and translation of the painter p is already set appropriately.

Reimplemented in QCanvasView and QTable.

void QScrollView::drawContentsOffset ( QPainter * p, int offsetx, int offsety, int clipx, int clipy, int clipw, int cliph ) [virtual protected]
For backward compatibility only. It is easier to use drawContents(QPainter*,int,int,int,int).

The default implementation translates the painter appropriately and calls drawContents(QPainter*,int,int,int,int).

Reimplemented in QListView and QTextView.

void QScrollView::enableClipper ( bool y )
When large numbers of child widgets are in a scrollview, especially if they are close together, the scrolling performance can suffer greatly. If you call enableClipper(TRUE), the scrollview will use an extra widget to group child widgets.

Note that you may only call enableClipper() prior to adding widgets.

For a full discussion, see the overview documentation of this class.

Examples: scrollview/scrollview.cpp

void QScrollView::ensureVisible ( int x, int y ) [slot]
Scrolls the content so that the point (x, y) is visible with at least 50-pixel margins (if possible, otherwise centered).

void QScrollView::ensureVisible ( int x, int y, int xmargin, int ymargin ) [slot]
Scrolls the content so that the point (x, y) is visible with at least the given pixel margins (if possible, otherwise centered).

bool QScrollView::eventFilter ( QObject * obj, QEvent * e ) [virtual protected]
This event filter ensures the scrollbars are updated when a single contents widget is resized, shown, hidden, or destroyed, and passes mouse events to the QScrollView.

Reimplemented from QObject.

bool QScrollView::focusNextPrevChild ( bool next ) [virtual protected]
Reimplemented for internal reasons; the API is not affected.

Reimplemented from QWidget.

void QScrollView::frameChanged () [virtual protected]
Reimplemented for internal reasons; the API is not affected.

Reimplemented from QFrame.

QScrollView::ScrollBarMode QScrollView::hScrollBarMode() const
Returns the currently set mode for the horizontal scrollbar.

See also setHScrollBarMode().

Examples: scrollview/scrollview.cpp

bool QScrollView::hasStaticBackground () const
Returns wether QScrollView uses a static background.

See also setStaticBackground().

QScrollBar* QScrollView::horizontalScrollBar () const
Returns the component horizontal scrollbar. It is made available to allow accelerators, autoscrolling, etc., and to allow changing of arrow scroll rates: bar->setSteps( rate, bar->pageStep() ).

It should not be otherwise manipulated.

This function never returns 0.

int QScrollView::leftMargin () const [protected]
Returns the current left margin.

See also setMargins().

QSize QScrollView::minimumSizeHint () const [virtual]
Reimplemented for internal reasons; the API is not affected.

Reimplemented from QWidget.

void QScrollView::moveChild ( QWidget * child, int x, int y ) [virtual]
Repositions child to (x, y). This functions the same as addChild().

void QScrollView::removeChild ( QObject * child ) [virtual]
Reimplemented for internal reasons; the API is not affected.

Reimplemented from QObject.

void QScrollView::removeChild ( QWidget * child )
Removes a child from the scrolled area. Note that this happens automatically if the child is deleted.

void QScrollView::repaintContents ( int x, int y, int w, int h, bool erase=TRUE )
Calls repaint() on rectangle defined by x, y, w, h, translated appropriately. If the rectangle in not visible, nothing is repainted.

See also updateContents().

void QScrollView::repaintContents ( const QRect & r, bool erase=TRUE )
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

void QScrollView::resize ( const QSize & s )
Reimplemented for internal reasons; the API is not affected.

Examples: iconview/main.cpp dirview/main.cpp

void QScrollView::resize ( int w, int h )
Reimplemented for internal reasons; the API is not affected.

void QScrollView::resizeContents ( int w, int h ) [virtual slot]
Set the size of the contents area to w pixels wide and h pixels high, and updates the viewport accordingly.

void QScrollView::resizeEvent ( QResizeEvent * event ) [virtual protected]
Reimplemented for internal reasons; the API is not affected.

Reimplemented from QWidget.

QScrollView::ResizePolicy QScrollView::resizePolicy() const
Returns the currently set ResizePolicy.

See also setResizePolicy() and ResizePolicy.

int QScrollView::rightMargin () const [protected]
Returns the current right margin.

See also setMargins().

void QScrollView::scrollBy ( int dx, int dy ) [slot]
Scrolls the content by x to the left and y upwards.

void QScrollView::setContentsPos ( int x, int y ) [virtual slot]
Scrolls the content so that the point (x, y) is in the top-left corner.

Reimplemented in QListView.

void QScrollView::setCornerWidget ( QWidget * corner ) [virtual]
Sets the widget in the corner between the two scrollbars.

You will probably also want to set at least one of the scrollbar 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 QScrollView when it destructs 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.

See also setVScrollBarMode() and setHScrollBarMode().

Examples: scrollview/scrollview.cpp

void QScrollView::setDragAutoScroll ( bool b )
If b is set to TRUE, the QScrollView automatically scrolls the contents in drag move events if the user moves the cursor close to a border of the view. This of course only works id the viewport accepts drops! Specifying FALSE here disables this autoscroll feature.

void QScrollView::setEnabled ( bool enable ) [virtual slot]
Reimplemented for internal reasons; the API is not affected.

Reimplemented from QWidget.

void QScrollView::setHBarGeometry ( QScrollBar & hbar, int x, int y, int w, int h ) [virtual protected]
Called when the horizontal scrollbar geometry changes. This is provided as a protected function so that subclasses can do interesting things like providing extra buttons in some of the space normally used by the scrollbars.

The default implementation simply gives all the space to hbar.

See also setVBarGeometry().

void QScrollView::setHScrollBarMode ( ScrollBarMode mode )
Sets the mode for the horizontal scrollbar.

Auto (the default) shows a scrollbar when the content is too wide to fit.

AlwaysOff never shows a scrollbar.

AlwaysOn always shows a scrollbar.

See also hScrollBarMode() and setVScrollBarMode().

Examples: scrollview/scrollview.cpp

void QScrollView::setMargins ( int left, int top, int right, int bottom ) [virtual protected]
Sets the margins around the scrolling area. This is useful for applications such as spreadsheets with `locked' rows and columns. The marginal space is inside the frameRect() and is left blank - reimplement drawContents() or put widgets in the unused area.

By default all margins are zero.

See also frameChanged().

void QScrollView::setResizePolicy ( ResizePolicy r )
Sets the resize policy to r.

See also resizePolicy() and ResizePolicy.

void QScrollView::setStaticBackground ( bool y )
Sets the scrollview to have a static background if y is TRUE, or a scrolling background otherwise. By default, the background is scrolling.

Beware that this mode is quite slow, as a full repaint of the visible area has to be triggered on every contents move.

See also hasStaticBackground().

void QScrollView::setVBarGeometry ( QScrollBar & vbar, int x, int y, int w, int h ) [virtual protected]
Called when the vertical scrollbar geometry changes. This is provided as a protected function so that subclasses can do interesting things like providing extra buttons in some of the space normally used by the scrollbars.

The default implementation simply gives all the space to vbar.

See also setHBarGeometry().

void QScrollView::setVScrollBarMode ( ScrollBarMode mode )
Sets the mode for the vertical scrollbar.

See also vScrollBarMode() and setHScrollBarMode().

Examples: scrollview/scrollview.cpp

void QScrollView::show () [virtual]
Reimplemented for internal reasons; the API is not affected.

Examples: iconview/main.cpp

Reimplemented from QWidget.

void QScrollView::showChild ( QWidget * child, bool y=TRUE )
This function is obsolete. It is provided to keep old source working, and will probably be removed in a future version of Qt. We strongly advise against using it in new code.

Sets the visibility of child. Equivalent to QWidget::show() or QWidget::hide().

QSize QScrollView::sizeHint () const [virtual]
Reimplemented for internal reasons; the API is not affected.

Reimplemented from QWidget.

QSizePolicy QScrollView::sizePolicy () const [virtual]
Reimplemented for internal reasons; the API is not affected.

Reimplemented from QWidget.

void QScrollView::styleChange ( QStyle & old ) [virtual]
Reimplemented for internal reasons; the API is not affected.

Reimplemented from QWidget.

int QScrollView::topMargin () const [protected]
Returns the current top margin.

See also setMargins().

void QScrollView::updateContents ( int x, int y, int w, int h )
Calls update() on rectangle defined by x, y, w, h, translated appropriately. If the rectangle in not visible, nothing is repainted.

See also repaintContents().

void QScrollView::updateContents ( const QRect & r )
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

void QScrollView::updateScrollBars () [slot]
Updates scrollbars - all possibilities considered. You should never need to call this in your code.

QScrollView::ScrollBarMode QScrollView::vScrollBarMode() const
Returns the currently set mode for the vertical scrollbar.

See also setVScrollBarMode().

Examples: scrollview/scrollview.cpp

QScrollBar* QScrollView::verticalScrollBar () const
Returns the component vertical scrollbar. It is made available to allow accelerators, autoscrolling, etc., and to allow changing of arrow scroll rates: bar->setSteps( rate, bar->pageStep() ).

It should not be otherwise manipulated.

This function never returns 0.

QWidget* QScrollView::viewport () const
Returns the viewport widget of the scrollview. This is the widget containing the contents widget or which is the drawing area.

Examples: scrollview/scrollview.cpp

void QScrollView::viewportDragEnterEvent ( QDragEnterEvent * e ) [virtual protected]
To provide simple processing of events on the contents, this method receives all drag enter events sent to the viewport.

The default implementation translates the event and calls contentsDragEnterEvent().

See also QWidget::dragEnterEvent().

void QScrollView::viewportDragLeaveEvent ( QDragLeaveEvent * e ) [virtual protected]
To provide simple processing of events on the contents, this method receives all drag leave events sent to the viewport.

The default implementation calls contentsDragLeaveEvent().

See also QWidget::dragLeaveEvent().

void QScrollView::viewportDragMoveEvent ( QDragMoveEvent * e ) [virtual protected]
To provide simple processing of events on the contents, this method receives all drag move events sent to the viewport.

The default implementation translates the event and calls contentsDragMoveEvent().

See also QWidget::dragMoveEvent().

void QScrollView::viewportDropEvent ( QDropEvent * e ) [virtual protected]
To provide simple processing of events on the contents, this method receives all drop events sent to the viewport.

The default implementation translates the event and calls contentsDropEvent().

See also QWidget::dropEvent().

void QScrollView::viewportMouseDoubleClickEvent ( QMouseEvent * e ) [virtual protected]
To provide simple processing of events on the contents, this method receives all mouse double click events sent to the viewport.

The default implementation translates the event and calls contentsMouseDoubleClickEvent().

See also QWidget::mouseDoubleClickEvent().

Reimplemented in QListBox.

void QScrollView::viewportMouseMoveEvent ( QMouseEvent * e ) [virtual protected]
To provide simple processing of events on the contents, this method receives all mouse move events sent to the viewport.

The default implementation translates the event and calls contentsMouseMoveEvent().

See also QWidget::mouseMoveEvent().

Reimplemented in QTextView, QTextBrowser and QListBox.

void QScrollView::viewportMousePressEvent ( QMouseEvent * e ) [virtual protected]
To provide simple processing of events on the contents, this method receives all mouse press events sent to the viewport.

The default implementation translates the event and calls contentsMousePressEvent().

See also contentsMousePressEvent() and QWidget::mousePressEvent().

Reimplemented in QTextView, QListBox and QTextBrowser.

void QScrollView::viewportMouseReleaseEvent ( QMouseEvent * e ) [virtual protected]
To provide simple processing of events on the contents, this method receives all mouse release events sent to the viewport.

The default implementation translates the event and calls contentsMouseReleaseEvent().

See also QWidget::mouseReleaseEvent().

Reimplemented in QListBox, QTextView and QTextBrowser.

void QScrollView::viewportPaintEvent ( QPaintEvent * pe ) [virtual protected]
This is a low-level painting routine that draws the viewport contents. Reimplement this if drawContents() is too high-level. (for example, if you don't want to open a QPainter on the viewport).

Reimplemented in QListBox.

void QScrollView::viewportResizeEvent ( QResizeEvent * ) [virtual protected]
To provide simple processing of events on the contents, this method receives all resize events sent to the viewport.

See also QWidget::resizeEvent().

Reimplemented in QTextView.

QSize QScrollView::viewportSize ( int x, int y ) const
Returns the viewport size for size (x, y).

The viewport size depends on x,y (the size of the contents), the size of this widget, the modes of the horizontal and vertical scroll bars.

This function permits widgets that can trade vertical and horizontal space for each other to control scroll bar appearance better. For example, a word processor or web browser can control the width of the right margin accurately, whether there needs to be a vertical scroll bar or not.

QPoint QScrollView::viewportToContents ( const QPoint & vp )
Returns the point on the viewport vp translated to a point in the contents.

void QScrollView::viewportToContents ( int vx, int vy, int & x, int & y )
Translates a point (vx, vy) on the viewport() widget to a point (x, y) in the contents.

void QScrollView::viewportWheelEvent ( QWheelEvent * e ) [virtual protected]
To provide simple processing of events on the contents, this method receives all wheel events sent to the viewport.

The default implementation translates the event and calls contentsWheelEvent().

See also QWidget::wheelEvent().

int QScrollView::visibleHeight () const
Returns the vertical amount of the content that is visible.

int QScrollView::visibleWidth () const
Returns the horizontal amount of the content that is visible.

void QScrollView::wheelEvent ( QWheelEvent * e ) [virtual protected]
Reimplemented for internal reasons; the API is not affected.

Reimplemented from QWidget.

SEE ALSO
http://doc.trolltech.com/qscrollview.html http://www.trolltech.com/faq/tech.html

COPYRIGHT
Copyright 1992-2001 Trolltech AS, http://www.trolltech.com. See the license file included in the distribution for a complete license statement.

AUTHOR
Generated automatically from the source code.

BUGS
If you find a bug in Qt, please report it as described in http://doc.trolltech.com/bughowto.html. Good bug reports make our job much simpler. Thank you.

In case of content or formattting problems with this manual page, please report them to qt-bugs@trolltech.com. Please include the name of the manual page (qscrollview.3qt) and the Qt version (2.3.1).