source: trunk/doc/html/qscrollview.html@ 190

Last change on this file since 190 was 190, checked in by rudi, 14 years ago

reference documentation added

File size: 60.6 KB
Line 
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/src/widgets/qscrollview.cpp:347 -->
3<html>
4<head>
5<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
6<title>QScrollView Class</title>
7<style type="text/css"><!--
8fn { margin-left: 1cm; text-indent: -1cm; }
9a:link { color: #004faf; text-decoration: none }
10a:visited { color: #672967; text-decoration: none }
11body { background: #ffffff; color: black; }
12--></style>
13</head>
14<body>
15
16<table border="0" cellpadding="0" cellspacing="0" width="100%">
17<tr bgcolor="#E5E5E5">
18<td valign=center>
19 <a href="index.html">
20<font color="#004faf">Home</font></a>
21 | <a href="classes.html">
22<font color="#004faf">All&nbsp;Classes</font></a>
23 | <a href="mainclasses.html">
24<font color="#004faf">Main&nbsp;Classes</font></a>
25 | <a href="annotated.html">
26<font color="#004faf">Annotated</font></a>
27 | <a href="groups.html">
28<font color="#004faf">Grouped&nbsp;Classes</font></a>
29 | <a href="functions.html">
30<font color="#004faf">Functions</font></a>
31</td>
32<td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>QScrollView Class Reference</h1>
33
34<p>The QScrollView widget provides a scrolling area with on-demand scroll bars.
35<a href="#details">More...</a>
36<p><tt>#include &lt;<a href="qscrollview-h.html">qscrollview.h</a>&gt;</tt>
37<p>Inherits <a href="qframe.html">QFrame</a>.
38<p>Inherited by <a href="qcanvasview.html">QCanvasView</a>, <a href="qtable.html">QTable</a>, <a href="qgridview.html">QGridView</a>, <a href="qiconview.html">QIconView</a>, <a href="qlistbox.html">QListBox</a>, <a href="qlistview.html">QListView</a>, and <a href="qtextedit.html">QTextEdit</a>.
39<p><a href="qscrollview-members.html">List of all member functions.</a>
40<h2>Public Members</h2>
41<ul>
42<li class=fn><a href="#QScrollView"><b>QScrollView</b></a> ( QWidget&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;name = 0, WFlags&nbsp;f = 0 )</li>
43<li class=fn><a href="#~QScrollView"><b>~QScrollView</b></a> ()</li>
44<li class=fn>enum <a href="#ResizePolicy-enum"><b>ResizePolicy</b></a> { Default, Manual, AutoOne, AutoOneFit }</li>
45<li class=fn>virtual void <a href="#setResizePolicy"><b>setResizePolicy</b></a> ( ResizePolicy )</li>
46<li class=fn>ResizePolicy <a href="#resizePolicy"><b>resizePolicy</b></a> () const</li>
47<li class=fn>void <a href="#removeChild"><b>removeChild</b></a> ( QWidget&nbsp;*&nbsp;child )</li>
48<li class=fn>virtual void <a href="#addChild"><b>addChild</b></a> ( QWidget&nbsp;*&nbsp;child, int&nbsp;x = 0, int&nbsp;y = 0 )</li>
49<li class=fn>virtual void <a href="#moveChild"><b>moveChild</b></a> ( QWidget&nbsp;*&nbsp;child, int&nbsp;x, int&nbsp;y )</li>
50<li class=fn>int <a href="#childX"><b>childX</b></a> ( QWidget&nbsp;*&nbsp;child )</li>
51<li class=fn>int <a href="#childY"><b>childY</b></a> ( QWidget&nbsp;*&nbsp;child )</li>
52<li class=fn>bool childIsVisible ( QWidget&nbsp;*&nbsp;child ) &nbsp;<em>(obsolete)</em></li>
53<li class=fn>void showChild ( QWidget&nbsp;*&nbsp;child, bool&nbsp;y = TRUE ) &nbsp;<em>(obsolete)</em></li>
54<li class=fn>enum <a href="#ScrollBarMode-enum"><b>ScrollBarMode</b></a> { Auto, AlwaysOff, AlwaysOn }</li>
55<li class=fn>ScrollBarMode <a href="#vScrollBarMode"><b>vScrollBarMode</b></a> () const</li>
56<li class=fn>virtual void <a href="#setVScrollBarMode"><b>setVScrollBarMode</b></a> ( ScrollBarMode )</li>
57<li class=fn>ScrollBarMode <a href="#hScrollBarMode"><b>hScrollBarMode</b></a> () const</li>
58<li class=fn>virtual void <a href="#setHScrollBarMode"><b>setHScrollBarMode</b></a> ( ScrollBarMode )</li>
59<li class=fn>QWidget * <a href="#cornerWidget"><b>cornerWidget</b></a> () const</li>
60<li class=fn>virtual void <a href="#setCornerWidget"><b>setCornerWidget</b></a> ( QWidget&nbsp;*&nbsp;corner )</li>
61<li class=fn>QScrollBar * <a href="#horizontalScrollBar"><b>horizontalScrollBar</b></a> () const</li>
62<li class=fn>QScrollBar * <a href="#verticalScrollBar"><b>verticalScrollBar</b></a> () const</li>
63<li class=fn>QWidget * <a href="#viewport"><b>viewport</b></a> () const</li>
64<li class=fn>QWidget * <a href="#clipper"><b>clipper</b></a> () const</li>
65<li class=fn>int <a href="#visibleWidth"><b>visibleWidth</b></a> () const</li>
66<li class=fn>int <a href="#visibleHeight"><b>visibleHeight</b></a> () const</li>
67<li class=fn>int <a href="#contentsWidth"><b>contentsWidth</b></a> () const</li>
68<li class=fn>int <a href="#contentsHeight"><b>contentsHeight</b></a> () const</li>
69<li class=fn>int <a href="#contentsX"><b>contentsX</b></a> () const</li>
70<li class=fn>int <a href="#contentsY"><b>contentsY</b></a> () const</li>
71<li class=fn>void <a href="#updateContents"><b>updateContents</b></a> ( int&nbsp;x, int&nbsp;y, int&nbsp;w, int&nbsp;h )</li>
72<li class=fn>void <a href="#updateContents-2"><b>updateContents</b></a> ( const&nbsp;QRect&nbsp;&amp;&nbsp;r )</li>
73<li class=fn>void <a href="#updateContents-3"><b>updateContents</b></a> ()</li>
74<li class=fn>void <a href="#repaintContents"><b>repaintContents</b></a> ( int&nbsp;x, int&nbsp;y, int&nbsp;w, int&nbsp;h, bool&nbsp;erase = TRUE )</li>
75<li class=fn>void <a href="#repaintContents-2"><b>repaintContents</b></a> ( const&nbsp;QRect&nbsp;&amp;&nbsp;r, bool&nbsp;erase = TRUE )</li>
76<li class=fn>void <a href="#repaintContents-3"><b>repaintContents</b></a> ( bool&nbsp;erase = TRUE )</li>
77<li class=fn>void <a href="#contentsToViewport"><b>contentsToViewport</b></a> ( int&nbsp;x, int&nbsp;y, int&nbsp;&amp;&nbsp;vx, int&nbsp;&amp;&nbsp;vy ) const</li>
78<li class=fn>void <a href="#viewportToContents"><b>viewportToContents</b></a> ( int&nbsp;vx, int&nbsp;vy, int&nbsp;&amp;&nbsp;x, int&nbsp;&amp;&nbsp;y ) const</li>
79<li class=fn>QPoint <a href="#contentsToViewport-2"><b>contentsToViewport</b></a> ( const&nbsp;QPoint&nbsp;&amp;&nbsp;p ) const</li>
80<li class=fn>QPoint <a href="#viewportToContents-2"><b>viewportToContents</b></a> ( const&nbsp;QPoint&nbsp;&amp;&nbsp;vp ) const</li>
81<li class=fn>void <a href="#enableClipper"><b>enableClipper</b></a> ( bool&nbsp;y )</li>
82<li class=fn>void <a href="#setStaticBackground"><b>setStaticBackground</b></a> ( bool&nbsp;y )</li>
83<li class=fn>bool <a href="#hasStaticBackground"><b>hasStaticBackground</b></a> () const</li>
84<li class=fn>QSize <a href="#viewportSize"><b>viewportSize</b></a> ( int&nbsp;x, int&nbsp;y ) const</li>
85<li class=fn>bool <a href="#isHorizontalSliderPressed"><b>isHorizontalSliderPressed</b></a> ()</li>
86<li class=fn>bool <a href="#isVerticalSliderPressed"><b>isVerticalSliderPressed</b></a> ()</li>
87<li class=fn>virtual void <a href="#setDragAutoScroll"><b>setDragAutoScroll</b></a> ( bool&nbsp;b )</li>
88<li class=fn>bool <a href="#dragAutoScroll"><b>dragAutoScroll</b></a> () const</li>
89</ul>
90<h2>Public Slots</h2>
91<ul>
92<li class=fn>virtual void <a href="#resizeContents"><b>resizeContents</b></a> ( int&nbsp;w, int&nbsp;h )</li>
93<li class=fn>void <a href="#scrollBy"><b>scrollBy</b></a> ( int&nbsp;dx, int&nbsp;dy )</li>
94<li class=fn>virtual void <a href="#setContentsPos"><b>setContentsPos</b></a> ( int&nbsp;x, int&nbsp;y )</li>
95<li class=fn>void <a href="#ensureVisible"><b>ensureVisible</b></a> ( int&nbsp;x, int&nbsp;y )</li>
96<li class=fn>void <a href="#ensureVisible-2"><b>ensureVisible</b></a> ( int&nbsp;x, int&nbsp;y, int&nbsp;xmargin, int&nbsp;ymargin )</li>
97<li class=fn>void <a href="#center"><b>center</b></a> ( int&nbsp;x, int&nbsp;y )</li>
98<li class=fn>void <a href="#center-2"><b>center</b></a> ( int&nbsp;x, int&nbsp;y, float&nbsp;xmargin, float&nbsp;ymargin )</li>
99<li class=fn>void <a href="#updateScrollBars"><b>updateScrollBars</b></a> ()</li>
100</ul>
101<h2>Signals</h2>
102<ul>
103<li class=fn>void <a href="#contentsMoving"><b>contentsMoving</b></a> ( int&nbsp;x, int&nbsp;y )</li>
104<li class=fn>void <a href="#horizontalSliderPressed"><b>horizontalSliderPressed</b></a> ()</li>
105<li class=fn>void <a href="#horizontalSliderReleased"><b>horizontalSliderReleased</b></a> ()</li>
106<li class=fn>void <a href="#verticalSliderPressed"><b>verticalSliderPressed</b></a> ()</li>
107<li class=fn>void <a href="#verticalSliderReleased"><b>verticalSliderReleased</b></a> ()</li>
108</ul>
109<h2>Properties</h2>
110<ul>
111<li class=fn>int <a href="#contentsHeight-prop"><b>contentsHeight</b></a>&nbsp;- the height of the contents area &nbsp;<em>(read only)</em></li>
112<li class=fn>int <a href="#contentsWidth-prop"><b>contentsWidth</b></a>&nbsp;- the width of the contents area &nbsp;<em>(read only)</em></li>
113<li class=fn>int <a href="#contentsX-prop"><b>contentsX</b></a>&nbsp;- the X coordinate of the contents that are at the left edge of the viewport &nbsp;<em>(read only)</em></li>
114<li class=fn>int <a href="#contentsY-prop"><b>contentsY</b></a>&nbsp;- the Y coordinate of the contents that are at the top edge of the viewport &nbsp;<em>(read only)</em></li>
115<li class=fn>bool <a href="#dragAutoScroll-prop"><b>dragAutoScroll</b></a>&nbsp;- whether autoscrolling in drag move events is enabled</li>
116<li class=fn>ScrollBarMode <a href="#hScrollBarMode-prop"><b>hScrollBarMode</b></a>&nbsp;- the mode for the horizontal scroll bar</li>
117<li class=fn>ResizePolicy <a href="#resizePolicy-prop"><b>resizePolicy</b></a>&nbsp;- the resize policy</li>
118<li class=fn>ScrollBarMode <a href="#vScrollBarMode-prop"><b>vScrollBarMode</b></a>&nbsp;- the mode for the vertical scroll bar</li>
119<li class=fn>int <a href="#visibleHeight-prop"><b>visibleHeight</b></a>&nbsp;- the vertical amount of the content that is visible &nbsp;<em>(read only)</em></li>
120<li class=fn>int <a href="#visibleWidth-prop"><b>visibleWidth</b></a>&nbsp;- the horizontal amount of the content that is visible &nbsp;<em>(read only)</em></li>
121</ul>
122<h2>Protected Members</h2>
123<ul>
124<li class=fn>virtual void <a href="#drawContents"><b>drawContents</b></a> ( QPainter&nbsp;*&nbsp;p, int&nbsp;clipx, int&nbsp;clipy, int&nbsp;clipw, int&nbsp;cliph )</li>
125<li class=fn>virtual void <a href="#drawContentsOffset"><b>drawContentsOffset</b></a> ( QPainter&nbsp;*&nbsp;p, int&nbsp;offsetx, int&nbsp;offsety, int&nbsp;clipx, int&nbsp;clipy, int&nbsp;clipw, int&nbsp;cliph )</li>
126<li class=fn>virtual void <a href="#contentsMousePressEvent"><b>contentsMousePressEvent</b></a> ( QMouseEvent&nbsp;*&nbsp;e )</li>
127<li class=fn>virtual void <a href="#contentsMouseReleaseEvent"><b>contentsMouseReleaseEvent</b></a> ( QMouseEvent&nbsp;*&nbsp;e )</li>
128<li class=fn>virtual void <a href="#contentsMouseDoubleClickEvent"><b>contentsMouseDoubleClickEvent</b></a> ( QMouseEvent&nbsp;*&nbsp;e )</li>
129<li class=fn>virtual void <a href="#contentsMouseMoveEvent"><b>contentsMouseMoveEvent</b></a> ( QMouseEvent&nbsp;*&nbsp;e )</li>
130<li class=fn>virtual void <a href="#contentsDragEnterEvent"><b>contentsDragEnterEvent</b></a> ( QDragEnterEvent * )</li>
131<li class=fn>virtual void <a href="#contentsDragMoveEvent"><b>contentsDragMoveEvent</b></a> ( QDragMoveEvent * )</li>
132<li class=fn>virtual void <a href="#contentsDragLeaveEvent"><b>contentsDragLeaveEvent</b></a> ( QDragLeaveEvent * )</li>
133<li class=fn>virtual void <a href="#contentsDropEvent"><b>contentsDropEvent</b></a> ( QDropEvent * )</li>
134<li class=fn>virtual void <a href="#contentsWheelEvent"><b>contentsWheelEvent</b></a> ( QWheelEvent&nbsp;*&nbsp;e )</li>
135<li class=fn>virtual void <a href="#contentsContextMenuEvent"><b>contentsContextMenuEvent</b></a> ( QContextMenuEvent&nbsp;*&nbsp;e )</li>
136<li class=fn>virtual void <a href="#viewportPaintEvent"><b>viewportPaintEvent</b></a> ( QPaintEvent&nbsp;*&nbsp;pe )</li>
137<li class=fn>virtual void <a href="#viewportResizeEvent"><b>viewportResizeEvent</b></a> ( QResizeEvent * )</li>
138<li class=fn>virtual void <a href="#setMargins"><b>setMargins</b></a> ( int&nbsp;left, int&nbsp;top, int&nbsp;right, int&nbsp;bottom )</li>
139<li class=fn>int <a href="#leftMargin"><b>leftMargin</b></a> () const</li>
140<li class=fn>int <a href="#topMargin"><b>topMargin</b></a> () const</li>
141<li class=fn>int <a href="#rightMargin"><b>rightMargin</b></a> () const</li>
142<li class=fn>int <a href="#bottomMargin"><b>bottomMargin</b></a> () const</li>
143<li class=fn>virtual void <a href="#setHBarGeometry"><b>setHBarGeometry</b></a> ( QScrollBar&nbsp;&amp;&nbsp;hbar, int&nbsp;x, int&nbsp;y, int&nbsp;w, int&nbsp;h )</li>
144<li class=fn>virtual void <a href="#setVBarGeometry"><b>setVBarGeometry</b></a> ( QScrollBar&nbsp;&amp;&nbsp;vbar, int&nbsp;x, int&nbsp;y, int&nbsp;w, int&nbsp;h )</li>
145<li class=fn>virtual bool <a href="#eventFilter"><b>eventFilter</b></a> ( QObject&nbsp;*&nbsp;obj, QEvent&nbsp;*&nbsp;e )</li>
146</ul>
147<hr><a name="details"></a><h2>Detailed Description</h2>
148
149
150The QScrollView widget provides a scrolling area with on-demand scroll bars.
151<p>
152
153<p> The QScrollView is a large canvas - potentially larger than the
154coordinate system normally supported by the underlying window
155system. This is important because it is quite easy to go beyond
156these limitations (e.g. many web pages are more than 32000 pixels
157high). Additionally, the QScrollView can have QWidgets positioned
158on it that scroll around with the drawn content. These sub-widgets
159can also have positions outside the normal coordinate range (but
160they are still limited in size).
161<p> To provide content for the widget, inherit from QScrollView,
162reimplement <a href="#drawContents">drawContents</a>() and use <a href="#resizeContents">resizeContents</a>() to set the
163size of the viewed area. Use <a href="#addChild">addChild</a>() and <a href="#moveChild">moveChild</a>() to
164position widgets on the view.
165<p> To use QScrollView effectively it is important to understand its
166widget structure in the three styles of use: a single large child
167widget, a large panning area with some widgets and a large panning
168area with many widgets.
169<p> <h3> Using One Big Widget
170</h3>
171<a name="1"></a><p> <center><img src="qscrollview-vp2.png"></center>
172<p> The first, simplest usage of QScrollView (depicted above), is
173appropriate for scrolling areas that are never more than about
1744000 pixels in either dimension (this is about the maximum
175reliable size on X11 servers). In this usage, you just make one
176large child in the QScrollView. The child should be a child of the
177<a href="#viewport">viewport</a>() of the scrollview and be added with addChild():
178<pre>
179 QScrollView* sv = new QScrollView(...);
180 <a href="qvbox.html">QVBox</a>* big_box = new <a href="qvbox.html">QVBox</a>(sv-&gt;<a href="#viewport">viewport</a>());
181 sv-&gt;<a href="#addChild">addChild</a>(big_box);
182 </pre>
183
184You can go on to add arbitrary child widgets to the single child
185in the scrollview as you would with any widget:
186<pre>
187 <a href="qlabel.html">QLabel</a>* child1 = new <a href="qlabel.html">QLabel</a>("CHILD", big_box);
188 <a href="qlabel.html">QLabel</a>* child2 = new <a href="qlabel.html">QLabel</a>("CHILD", big_box);
189 <a href="qlabel.html">QLabel</a>* child3 = new <a href="qlabel.html">QLabel</a>("CHILD", big_box);
190 ...
191 </pre>
192
193<p> Here the QScrollView has four children: the viewport(), the
194<a href="#verticalScrollBar">verticalScrollBar</a>(), the <a href="#horizontalScrollBar">horizontalScrollBar</a>() and a small
195<a href="#cornerWidget">cornerWidget</a>(). The <a href="#viewport">viewport</a>() has one child: the big <a href="qvbox.html">QVBox</a>. The
196QVBox has the three <a href="qlabel.html">QLabel</a> objects as child widgets. When the view
197is scrolled, the QVBox is moved; its children move with it as
198child widgets normally do.
199<p> <h3> Using a Very Big View with Some Widgets
200</h3>
201<a name="1-1"></a><p> <center><img src="qscrollview-vp.png"></center>
202<p> The second usage of QScrollView (depicted above) is appropriate
203when few, if any, widgets are on a very large scrolling area that
204is potentially larger than 4000 pixels in either dimension. In
205this usage you call <a href="#resizeContents">resizeContents</a>() to set the size of the area
206and reimplement <a href="#drawContents">drawContents</a>() to paint the contents. You may also
207add some widgets by making them children of the viewport() and
208adding them with <a href="#addChild">addChild</a>() (this is the same as the process for
209the single large widget in the previous example):
210<pre>
211 QScrollView* sv = new QScrollView(...);
212 <a href="qlabel.html">QLabel</a>* child1 = new <a href="qlabel.html">QLabel</a>("CHILD", sv-&gt;<a href="#viewport">viewport</a>());
213 sv-&gt;<a href="#addChild">addChild</a>(child1);
214 <a href="qlabel.html">QLabel</a>* child2 = new <a href="qlabel.html">QLabel</a>("CHILD", sv-&gt;<a href="#viewport">viewport</a>());
215 sv-&gt;<a href="#addChild">addChild</a>(child2);
216 <a href="qlabel.html">QLabel</a>* child3 = new <a href="qlabel.html">QLabel</a>("CHILD", sv-&gt;<a href="#viewport">viewport</a>());
217 sv-&gt;<a href="#addChild">addChild</a>(child3);
218 </pre>
219
220Here, the QScrollView has the same four children: the <a href="#viewport">viewport</a>(),
221the <a href="#verticalScrollBar">verticalScrollBar</a>(), the <a href="#horizontalScrollBar">horizontalScrollBar</a>() and a small
222<a href="#cornerWidget">cornerWidget</a>(). The viewport() has the three <a href="qlabel.html">QLabel</a> objects as
223child widgets. When the view is scrolled, the scrollview moves the
224child widgets individually.
225<p> <h3> Using a Very Big View with Many Widgets
226</h3>
227<a name="1-2"></a><p> <a name="enableclipper"></a>
228<center><img src="qscrollview-cl.png"></center>
229<p> The final usage of QScrollView (depicted above) is appropriate
230when many widgets are on a very large scrolling area that is
231potentially larger than 4000 pixels in either dimension. In this
232usage you call <a href="#resizeContents">resizeContents</a>() to set the size of the area and
233reimplement <a href="#drawContents">drawContents</a>() to paint the contents. You then call
234<a href="#enableClipper">enableClipper</a>(TRUE) and add widgets, again by making them children
235of the <a href="#viewport">viewport</a>(), and adding them with <a href="#addChild">addChild</a>():
236<pre>
237 QScrollView* sv = new QScrollView(...);
238 sv-&gt;<a href="#enableClipper">enableClipper</a>(TRUE);
239 <a href="qlabel.html">QLabel</a>* child1 = new <a href="qlabel.html">QLabel</a>("CHILD", sv-&gt;<a href="#viewport">viewport</a>());
240 sv-&gt;<a href="#addChild">addChild</a>(child1);
241 <a href="qlabel.html">QLabel</a>* child2 = new <a href="qlabel.html">QLabel</a>("CHILD", sv-&gt;<a href="#viewport">viewport</a>());
242 sv-&gt;<a href="#addChild">addChild</a>(child2);
243 <a href="qlabel.html">QLabel</a>* child3 = new <a href="qlabel.html">QLabel</a>("CHILD", sv-&gt;<a href="#viewport">viewport</a>());
244 sv-&gt;<a href="#addChild">addChild</a>(child3);
245 </pre>
246
247<p> Here, the QScrollView has four children: the <a href="#clipper">clipper</a>() (not the
248viewport() this time), the <a href="#verticalScrollBar">verticalScrollBar</a>(), the
249<a href="#horizontalScrollBar">horizontalScrollBar</a>() and a small <a href="#cornerWidget">cornerWidget</a>(). The clipper()
250has one child: the <a href="#viewport">viewport</a>(). The viewport() has the same three
251labels as child widgets. When the view is scrolled the viewport()
252is moved; its children move with it as child widgets normally do.
253<p> <a name="allviews"></a>
254<h3> Details Relevant for All Views
255</h3>
256<a name="1-3"></a><p> Normally you will use the first or third method if you want any
257child widgets in the view.
258<p> Note that the widget you see in the scrolled area is the
259viewport() widget, not the QScrollView itself. So to turn mouse
260tracking on, for example, use viewport()->setMouseTracking(TRUE).
261<p> To enable drag-and-drop, you would <a href="qwidget.html#setAcceptDrops">setAcceptDrops</a>(TRUE) on the
262QScrollView (because drag-and-drop events propagate to the
263parent). But to work out the logical position in the view, you
264would need to map the drop co-ordinate from being relative to the
265QScrollView to being relative to the contents; use the function
266<a href="#viewportToContents">viewportToContents</a>() for this.
267<p> To handle mouse events on the scrolling area, subclass scrollview
268as you would subclass other widgets, but rather than
269reimplementing <a href="qwidget.html#mousePressEvent">mousePressEvent</a>(), reimplement
270<a href="#contentsMousePressEvent">contentsMousePressEvent</a>() instead. The contents specific event
271handlers provide translated events in the coordinate system of the
272scrollview. If you reimplement mousePressEvent(), you'll get
273called only when part of the QScrollView is clicked: and the only
274such part is the "corner" (if you don't set a <a href="#cornerWidget">cornerWidget</a>()) and
275the frame; everything else is covered up by the viewport, clipper
276or scroll bars.
277<p> When you construct a QScrollView, some of the widget flags apply
278to the <a href="#viewport">viewport</a>() instead of being sent to the <a href="qwidget.html">QWidget</a> constructor
279for the QScrollView. This applies to <a href="qt.html#WidgetFlags-enum">WNoAutoErase</a>, <a href="qt.html#WidgetFlags-enum">WStaticContents</a>, and <a href="qt.html#WidgetFlags-enum">WPaintClever</a>. See <a href="qt.html#WidgetFlags-enum">Qt::WidgetFlags</a> for
280documentation about these flags. Here are some examples:
281<p> <ul>
282<p> <li> An image-manipulation widget would use <tt>WNoAutoErase|WStaticContents</tt> because the widget draws all pixels
283itself, and when its size increases, it only needs a paint event
284for the new part because the old part remains unchanged.
285<p> <li> A scrolling game widget in which the background scrolls as the
286characters move might use <a href="qt.html#WidgetFlags-enum">WNoAutoErase</a> (in addition to <a href="qt.html#WidgetFlags-enum">WStaticContents</a>) so that the window system background does not
287flash in and out during scrolling.
288<p> <li> A word processing widget might use <a href="qt.html#WidgetFlags-enum">WNoAutoErase</a> and repaint
289itself line by line to get a less-flickery resizing. If the widget
290is in a mode in which no text justification can take place, it
291might use <a href="qt.html#WidgetFlags-enum">WStaticContents</a> too, so that it would only get a
292repaint for the newly visible parts.
293<p> </ul>
294<p> Child widgets may be moved using <a href="#addChild">addChild</a>() or <a href="#moveChild">moveChild</a>(). Use
295<a href="#childX">childX</a>() and <a href="#childY">childY</a>() to get the position of a child widget.
296<p> A widget may be placed in the corner between the vertical and
297horizontal scrollbars with <a href="#setCornerWidget">setCornerWidget</a>(). You can get access
298to the scrollbars using <a href="#horizontalScrollBar">horizontalScrollBar</a>() and
299<a href="#verticalScrollBar">verticalScrollBar</a>(), and to the viewport with <a href="#viewport">viewport</a>(). The
300scroll view can be scrolled using <a href="#scrollBy">scrollBy</a>(), <a href="#ensureVisible">ensureVisible</a>(),
301<a href="#setContentsPos">setContentsPos</a>() or <a href="#center">center</a>().
302<p> The visible area is given by <a href="#visibleWidth">visibleWidth</a>() and <a href="#visibleHeight">visibleHeight</a>(),
303and the contents area by <a href="#contentsWidth">contentsWidth</a>() and <a href="#contentsHeight">contentsHeight</a>(). The
304contents may be repainted using one of the <a href="#repaintContents">repaintContents</a>() or
305<a href="#updateContents">updateContents</a>() functions.
306<p> Coordinate conversion is provided by <a href="#contentsToViewport">contentsToViewport</a>() and
307<a href="#viewportToContents">viewportToContents</a>().
308<p> The <a href="#contentsMoving">contentsMoving</a>() signal is emitted just before the contents
309are moved to a new position.
310<p> <b>Warning:</b> QScrollView currently does not erase the background when
311resized, i.e. you must always clear the background manually in
312scrollview subclasses. This will change in a future version of Qt
313and we recommend specifying the WNoAutoErase flag explicitly.
314<p> <img src=qscrollview-m.png> <img src=qscrollview-w.png>
315<p>See also <a href="abstractwidgets.html">Abstract Widget Classes</a>.
316
317<hr><h2>Member Type Documentation</h2>
318<h3 class=fn><a name="ResizePolicy-enum"></a>QScrollView::ResizePolicy</h3>
319
320<p> This enum type is used to control a QScrollView's reaction to
321resize events.
322<ul>
323<li><tt>QScrollView::Default</tt> - the QScrollView selects one of the other settings
324automatically when it has to. In this version of Qt, QScrollView
325changes to <a href="#ResizePolicy-enum">Manual</a> if you resize the contents with
326<a href="#resizeContents">resizeContents</a>() and to <a href="#ResizePolicy-enum">AutoOne</a> if a child is added.
327<li><tt>QScrollView::Manual</tt> - the contents stays the size set by resizeContents().
328<li><tt>QScrollView::AutoOne</tt> - if there is only one child widget the contents stays
329the size of that widget. Otherwise the behavior is undefined.
330<li><tt>QScrollView::AutoOneFit</tt> - if there is only one child widget the contents stays
331the size of that widget's <a href="qwidget.html#sizeHint">sizeHint</a>(). If the scrollview is resized
332larger than the child's sizeHint(), the child will be resized to
333fit. If there is more than one child, the behavior is undefined.
334</ul><p>
335<h3 class=fn><a name="ScrollBarMode-enum"></a>QScrollView::ScrollBarMode</h3>
336
337<p> This enum type describes the various modes of QScrollView's scroll
338bars.
339<ul>
340<li><tt>QScrollView::Auto</tt> - QScrollView shows a scroll bar when the content is
341too large to fit and not otherwise. This is the default.
342<li><tt>QScrollView::AlwaysOff</tt> - QScrollView never shows a scroll bar.
343<li><tt>QScrollView::AlwaysOn</tt> - QScrollView always shows a scroll bar.
344</ul><p> (The modes for the horizontal and vertical scroll bars are
345independent.)
346
347<hr><h2>Member Function Documentation</h2>
348<h3 class=fn><a name="QScrollView"></a>QScrollView::QScrollView ( <a href="qwidget.html">QWidget</a>&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;name = 0, WFlags&nbsp;f = 0 )
349</h3>
350Constructs a QScrollView called <em>name</em> with parent <em>parent</em> and
351widget flags <em>f</em>.
352<p> The widget flags <a href="qt.html#WidgetFlags-enum">WStaticContents</a>, <a href="qt.html#WidgetFlags-enum">WNoAutoErase</a> and <a href="qt.html#WidgetFlags-enum">WPaintClever</a> are propagated to the <a href="#viewport">viewport</a>() widget. The other
353widget flags are propagated to the parent constructor as usual.
354
355<h3 class=fn><a name="~QScrollView"></a>QScrollView::~QScrollView ()
356</h3>
357Destroys the QScrollView. Any children added with <a href="#addChild">addChild</a>() will
358be deleted.
359
360<h3 class=fn>void <a name="addChild"></a>QScrollView::addChild ( <a href="qwidget.html">QWidget</a>&nbsp;*&nbsp;child, int&nbsp;x = 0, int&nbsp;y = 0 )<tt> [virtual]</tt>
361</h3>
362Inserts the widget, <em>child</em>, into the scrolled area positioned at
363(<em>x</em>, <em>y</em>). The position defaults to (0, 0). If the child is
364already in the view, it is just moved.
365<p> You may want to call <a href="#enableClipper">enableClipper</a>(TRUE) if you add a large number
366of widgets.
367
368<p>Example: <a href="scrollview-example.html#x645">scrollview/scrollview.cpp</a>.
369<h3 class=fn>int <a name="bottomMargin"></a>QScrollView::bottomMargin () const<tt> [protected]</tt>
370</h3>
371Returns the bottom margin.
372<p> <p>See also <a href="#setMargins">setMargins</a>().
373
374<h3 class=fn>void <a name="center"></a>QScrollView::center ( int&nbsp;x, int&nbsp;y )<tt> [slot]</tt>
375</h3>
376Scrolls the content so that the point <em>(x, y)</em> is in the center
377of visible area.
378
379<p>Example: <a href="scrollview-example.html#x646">scrollview/scrollview.cpp</a>.
380<h3 class=fn>void <a name="center-2"></a>QScrollView::center ( int&nbsp;x, int&nbsp;y, float&nbsp;xmargin, float&nbsp;ymargin )<tt> [slot]</tt>
381</h3>
382This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
383<p> Scrolls the content so that the point <em>(x, y)</em> is visible with
384the <em>xmargin</em> and <em>ymargin</em> margins (as fractions of visible
385the area).
386<p> For example:
387<ul>
388<li> Margin 0.0 allows (x, y) to be on the edge of the visible area.
389<li> Margin 0.5 ensures that (x, y) is in middle 50% of the visible area.
390<li> Margin 1.0 ensures that (x, y) is in the center of the the visible area.
391</ul>
392
393<h3 class=fn>bool <a name="childIsVisible"></a>QScrollView::childIsVisible ( <a href="qwidget.html">QWidget</a>&nbsp;*&nbsp;child )
394</h3>
395<b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
396<p> Returns TRUE if <em>child</em> is visible. This is equivalent
397to child->isVisible().
398
399<h3 class=fn>int <a name="childX"></a>QScrollView::childX ( <a href="qwidget.html">QWidget</a>&nbsp;*&nbsp;child )
400</h3>
401Returns the X position of the given <em>child</em> widget. Use this
402rather than <a href="qwidget.html#x">QWidget::x</a>() for widgets added to the view.
403<p> This function returns 0 if <em>child</em> has not been added to the view.
404
405<h3 class=fn>int <a name="childY"></a>QScrollView::childY ( <a href="qwidget.html">QWidget</a>&nbsp;*&nbsp;child )
406</h3>
407Returns the Y position of the given <em>child</em> widget. Use this
408rather than <a href="qwidget.html#y">QWidget::y</a>() for widgets added to the view.
409<p> This function returns 0 if <em>child</em> has not been added to the view.
410
411<h3 class=fn><a href="qwidget.html">QWidget</a>&nbsp;* <a name="clipper"></a>QScrollView::clipper () const
412</h3>
413Returns the clipper widget. Contents in the scrollview are
414ultimately clipped to be inside the clipper widget.
415<p> You should not need to use this function.
416<p> <p>See also <a href="#visibleWidth-prop">visibleWidth</a> and <a href="#visibleHeight-prop">visibleHeight</a>.
417
418<h3 class=fn>void <a name="contentsContextMenuEvent"></a>QScrollView::contentsContextMenuEvent ( <a href="qcontextmenuevent.html">QContextMenuEvent</a>&nbsp;*&nbsp;e )<tt> [virtual protected]</tt>
419</h3>
420This event handler is called whenever the QScrollView receives a
421<a href="qwidget.html#contextMenuEvent">contextMenuEvent</a>() in <em>e</em>: the mouse position is translated to
422be a point on the contents.
423
424<p>Example: <a href="tutorial2-06.html#x2584">chart/canvasview.cpp</a>.
425<h3 class=fn>void <a name="contentsDragEnterEvent"></a>QScrollView::contentsDragEnterEvent ( <a href="qdragenterevent.html">QDragEnterEvent</a>&nbsp;* )<tt> [virtual protected]</tt>
426</h3>
427This event handler is called whenever the QScrollView receives a
428<a href="qwidget.html#dragEnterEvent">dragEnterEvent</a>(): the drag position is translated to be a point
429on the contents.
430
431<p>Reimplemented in <a href="qtable.html#contentsDragEnterEvent">QTable</a>.
432<h3 class=fn>void <a name="contentsDragLeaveEvent"></a>QScrollView::contentsDragLeaveEvent ( <a href="qdragleaveevent.html">QDragLeaveEvent</a>&nbsp;* )<tt> [virtual protected]</tt>
433</h3>
434This event handler is called whenever the QScrollView receives a
435<a href="qwidget.html#dragLeaveEvent">dragLeaveEvent</a>(): the drag position is translated to be a point
436on the contents.
437
438<p>Reimplemented in <a href="qtable.html#contentsDragLeaveEvent">QTable</a>.
439<h3 class=fn>void <a name="contentsDragMoveEvent"></a>QScrollView::contentsDragMoveEvent ( <a href="qdragmoveevent.html">QDragMoveEvent</a>&nbsp;* )<tt> [virtual protected]</tt>
440</h3>
441This event handler is called whenever the QScrollView receives a
442<a href="qwidget.html#dragMoveEvent">dragMoveEvent</a>(): the drag position is translated to be a point on
443the contents.
444
445<p>Reimplemented in <a href="qtable.html#contentsDragMoveEvent">QTable</a>.
446<h3 class=fn>void <a name="contentsDropEvent"></a>QScrollView::contentsDropEvent ( <a href="qdropevent.html">QDropEvent</a>&nbsp;* )<tt> [virtual protected]</tt>
447</h3>
448This event handler is called whenever the QScrollView receives a
449<a href="qwidget.html#dropEvent">dropEvent</a>(): the drop position is translated to be a point on the
450contents.
451
452<p>Reimplemented in <a href="qtable.html#contentsDropEvent">QTable</a>.
453<h3 class=fn>int <a name="contentsHeight"></a>QScrollView::contentsHeight () const
454</h3><p>Returns the height of the contents area.
455See the <a href="qscrollview.html#contentsHeight-prop">"contentsHeight"</a> property for details.
456<h3 class=fn>void <a name="contentsMouseDoubleClickEvent"></a>QScrollView::contentsMouseDoubleClickEvent ( <a href="qmouseevent.html">QMouseEvent</a>&nbsp;*&nbsp;e )<tt> [virtual protected]</tt>
457</h3>
458This event handler is called whenever the QScrollView receives a
459<a href="qwidget.html#mouseDoubleClickEvent">mouseDoubleClickEvent</a>(): the click position in <em>e</em> is translated to be a
460point on the contents.
461<p> The default implementation generates a normal mouse press event.
462
463<p>Reimplemented in <a href="qlistview.html#contentsMouseDoubleClickEvent">QListView</a>.
464<h3 class=fn>void <a name="contentsMouseMoveEvent"></a>QScrollView::contentsMouseMoveEvent ( <a href="qmouseevent.html">QMouseEvent</a>&nbsp;*&nbsp;e )<tt> [virtual protected]</tt>
465</h3>
466This event handler is called whenever the QScrollView receives a
467<a href="qwidget.html#mouseMoveEvent">mouseMoveEvent</a>(): the mouse position in <em>e</em> is translated to be a point
468on the contents.
469
470<p>Examples: <a href="canvas-example.html#x2950">canvas/canvas.cpp</a> and <a href="tutorial2-06.html#x2585">chart/canvasview.cpp</a>.
471<p>Reimplemented in <a href="qlistview.html#contentsMouseMoveEvent">QListView</a>.
472<h3 class=fn>void <a name="contentsMousePressEvent"></a>QScrollView::contentsMousePressEvent ( <a href="qmouseevent.html">QMouseEvent</a>&nbsp;*&nbsp;e )<tt> [virtual protected]</tt>
473</h3>
474This event handler is called whenever the QScrollView receives a
475<a href="qwidget.html#mousePressEvent">mousePressEvent</a>(): the press position in <em>e</em> is translated to be a point
476on the contents.
477
478<p>Examples: <a href="canvas-example.html#x2951">canvas/canvas.cpp</a> and <a href="tutorial2-06.html#x2586">chart/canvasview.cpp</a>.
479<p>Reimplemented in <a href="qlistview.html#contentsMousePressEvent">QListView</a>.
480<h3 class=fn>void <a name="contentsMouseReleaseEvent"></a>QScrollView::contentsMouseReleaseEvent ( <a href="qmouseevent.html">QMouseEvent</a>&nbsp;*&nbsp;e )<tt> [virtual protected]</tt>
481</h3>
482This event handler is called whenever the QScrollView receives a
483<a href="qwidget.html#mouseReleaseEvent">mouseReleaseEvent</a>(): the release position in <em>e</em> is translated to be a
484point on the contents.
485
486<p>Reimplemented in <a href="qlistview.html#contentsMouseReleaseEvent">QListView</a>.
487<h3 class=fn>void <a name="contentsMoving"></a>QScrollView::contentsMoving ( int&nbsp;x, int&nbsp;y )<tt> [signal]</tt>
488</h3>
489
490<p> This signal is emitted just before the contents are moved to
491position <em>(x, y)</em>.
492<p> <p>See also <a href="#contentsX-prop">contentsX</a> and <a href="#contentsY-prop">contentsY</a>.
493
494<h3 class=fn>void <a name="contentsToViewport"></a>QScrollView::contentsToViewport ( int&nbsp;x, int&nbsp;y, int&nbsp;&amp;&nbsp;vx, int&nbsp;&amp;&nbsp;vy ) const
495</h3>
496Translates a point (<em>x</em>, <em>y</em>) in the contents to a point (<em>vx</em>,
497<em>vy</em>) on the <a href="#viewport">viewport</a>() widget.
498
499<h3 class=fn><a href="qpoint.html">QPoint</a> <a name="contentsToViewport-2"></a>QScrollView::contentsToViewport ( const&nbsp;<a href="qpoint.html">QPoint</a>&nbsp;&amp;&nbsp;p ) const
500</h3>
501This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
502<p> Returns the point <em>p</em> translated to a point on the <a href="#viewport">viewport</a>()
503widget.
504
505<h3 class=fn>void <a name="contentsWheelEvent"></a>QScrollView::contentsWheelEvent ( <a href="qwheelevent.html">QWheelEvent</a>&nbsp;*&nbsp;e )<tt> [virtual protected]</tt>
506</h3>
507This event handler is called whenever the QScrollView receives a
508<a href="qwidget.html#wheelEvent">wheelEvent</a>() in <em>e</em>: the mouse position is translated to be a
509point on the contents.
510
511<h3 class=fn>int <a name="contentsWidth"></a>QScrollView::contentsWidth () const
512</h3><p>Returns the width of the contents area.
513See the <a href="qscrollview.html#contentsWidth-prop">"contentsWidth"</a> property for details.
514<h3 class=fn>int <a name="contentsX"></a>QScrollView::contentsX () const
515</h3><p>Returns the X coordinate of the contents that are at the left edge of the viewport.
516See the <a href="qscrollview.html#contentsX-prop">"contentsX"</a> property for details.
517<h3 class=fn>int <a name="contentsY"></a>QScrollView::contentsY () const
518</h3><p>Returns the Y coordinate of the contents that are at the top edge of the viewport.
519See the <a href="qscrollview.html#contentsY-prop">"contentsY"</a> property for details.
520<h3 class=fn><a href="qwidget.html">QWidget</a>&nbsp;* <a name="cornerWidget"></a>QScrollView::cornerWidget () const
521</h3>
522Returns the widget in the corner between the two scroll bars.
523<p> By default, no corner widget is present.
524
525<p>Example: <a href="scrollview-example.html#x647">scrollview/scrollview.cpp</a>.
526<h3 class=fn>bool <a name="dragAutoScroll"></a>QScrollView::dragAutoScroll () const
527</h3><p>Returns TRUE if autoscrolling in drag move events is enabled; otherwise returns FALSE.
528See the <a href="qscrollview.html#dragAutoScroll-prop">"dragAutoScroll"</a> property for details.
529<h3 class=fn>void <a name="drawContents"></a>QScrollView::drawContents ( <a href="qpainter.html">QPainter</a>&nbsp;*&nbsp;p, int&nbsp;clipx, int&nbsp;clipy, int&nbsp;clipw, int&nbsp;cliph )<tt> [virtual protected]</tt>
530</h3>
531
532<p> Reimplement this function if you are viewing a drawing area rather
533than a widget.
534<p> The function should draw the rectangle (<em>clipx</em>, <em>clipy</em>, <em>clipw</em>, <em>cliph</em>) of the contents using painter <em>p</em>. The clip
535rectangle is in the scrollview's coordinates.
536<p> For example:
537<pre>
538 {
539 // Fill a 40000 by 50000 rectangle at (100000,150000)
540
541 // Calculate the coordinates...
542 int x1 = 100000, y1 = 150000;
543 int x2 = x1+40000-1, y2 = y1+50000-1;
544
545 // Clip the coordinates so X/Windows will not have problems...
546 if (x1 &lt; clipx) x1=clipx;
547 if (y1 &lt; clipy) y1=clipy;
548 if (x2 &gt; clipx+clipw-1) x2=clipx+clipw-1;
549 if (y2 &gt; clipy+cliph-1) y2=clipy+cliph-1;
550
551 // Paint using the small coordinates...
552 if ( x2 &gt;= x1 &amp;&amp; y2 &gt;= y1 )
553 p-&gt;fillRect(x1, y1, x2-x1+1, y2-y1+1, red);
554 }
555 </pre>
556
557<p> The clip rectangle and translation of the painter <em>p</em> is already
558set appropriately.
559
560<p>Example: <a href="qdir-example.html#x1837">qdir/qdir.cpp</a>.
561<p>Reimplemented in <a href="qcanvasview.html#drawContents">QCanvasView</a> and <a href="qtable.html#drawContents">QTable</a>.
562<h3 class=fn>void <a name="drawContentsOffset"></a>QScrollView::drawContentsOffset ( <a href="qpainter.html">QPainter</a>&nbsp;*&nbsp;p, int&nbsp;offsetx, int&nbsp;offsety, int&nbsp;clipx, int&nbsp;clipy, int&nbsp;clipw, int&nbsp;cliph )<tt> [virtual protected]</tt>
563</h3>
564For backward-compatibility only. It is easier to use
565<a href="#drawContents">drawContents</a>(<a href="qpainter.html">QPainter</a>*,int,int,int,int).
566<p> The default implementation translates the painter appropriately
567and calls drawContents(QPainter*,int,int,int,int). See
568drawContents() for an explanation of the parameters <em>p</em>, <em>offsetx</em>, <em>offsety</em>, <em>clipx</em>, <em>clipy</em>, <em>clipw</em> and <em>cliph</em>.
569
570<p>Reimplemented in <a href="qlistview.html#drawContentsOffset">QListView</a>.
571<h3 class=fn>void <a name="enableClipper"></a>QScrollView::enableClipper ( bool&nbsp;y )
572</h3>
573When a large numbers of child widgets are in a scrollview,
574especially if they are close together, the scrolling performance
575can suffer greatly. If <em>y</em> is TRUE the scrollview will use an
576extra widget to group child widgets.
577<p> Note that you may only call <a href="#enableClipper">enableClipper</a>() prior to adding
578widgets.
579<p> For a full discussion, see this class's <a href="#enableclipper">detailed description</a>.
580
581<p>Example: <a href="scrollview-example.html#x648">scrollview/scrollview.cpp</a>.
582<h3 class=fn>void <a name="ensureVisible"></a>QScrollView::ensureVisible ( int&nbsp;x, int&nbsp;y )<tt> [slot]</tt>
583</h3>
584Scrolls the content so that the point <em>(x, y)</em> is visible with at
585least 50-pixel margins (if possible, otherwise centered).
586
587<h3 class=fn>void <a name="ensureVisible-2"></a>QScrollView::ensureVisible ( int&nbsp;x, int&nbsp;y, int&nbsp;xmargin, int&nbsp;ymargin )<tt> [slot]</tt>
588</h3>
589This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
590<p> Scrolls the content so that the point <em>(x, y)</em> is visible with at
591least the <em>xmargin</em> and <em>ymargin</em> margins (if possible,
592otherwise centered).
593
594<h3 class=fn>bool <a name="eventFilter"></a>QScrollView::eventFilter ( <a href="qobject.html">QObject</a>&nbsp;*&nbsp;obj, <a href="qevent.html">QEvent</a>&nbsp;*&nbsp;e )<tt> [virtual protected]</tt>
595</h3>
596This event filter ensures the scroll bars are updated when a
597single contents widget is resized, shown, hidden or destroyed; it
598passes mouse events to the QScrollView. The event is in <em>e</em> and
599the object is in <em>obj</em>.
600
601<p>Reimplemented from <a href="qobject.html#eventFilter">QObject</a>.
602<p>Reimplemented in <a href="qlistview.html#eventFilter">QListView</a>.
603<h3 class=fn><a href="qscrollview.html#ScrollBarMode-enum">ScrollBarMode</a> <a name="hScrollBarMode"></a>QScrollView::hScrollBarMode () const
604</h3><p>Returns the mode for the horizontal scroll bar.
605See the <a href="qscrollview.html#hScrollBarMode-prop">"hScrollBarMode"</a> property for details.
606<h3 class=fn>bool <a name="hasStaticBackground"></a>QScrollView::hasStaticBackground () const
607</h3>
608Returns TRUE if QScrollView uses a static background; otherwise
609returns FALSE.
610<p> <p>See also <a href="#setStaticBackground">setStaticBackground</a>().
611
612<h3 class=fn><a href="qscrollbar.html">QScrollBar</a>&nbsp;* <a name="horizontalScrollBar"></a>QScrollView::horizontalScrollBar () const
613</h3>
614Returns the component horizontal scroll bar. It is made available
615to allow accelerators, autoscrolling, etc.
616<p> It should not be used for other purposes.
617<p> This function never returns 0.
618
619<h3 class=fn>void <a name="horizontalSliderPressed"></a>QScrollView::horizontalSliderPressed ()<tt> [signal]</tt>
620</h3>
621
622<p> This signal is emitted whenever the user presses the horizontal slider.
623
624<h3 class=fn>void <a name="horizontalSliderReleased"></a>QScrollView::horizontalSliderReleased ()<tt> [signal]</tt>
625</h3>
626
627<p> This signal is emitted whenever the user releases the horizontal slider.
628
629<h3 class=fn>bool <a name="isHorizontalSliderPressed"></a>QScrollView::isHorizontalSliderPressed ()
630</h3>
631Returns TRUE if horizontal slider is pressed by user; otherwise returns FALSE.
632
633<h3 class=fn>bool <a name="isVerticalSliderPressed"></a>QScrollView::isVerticalSliderPressed ()
634</h3>
635Returns TRUE if vertical slider is pressed by user; otherwise returns FALSE.
636
637<h3 class=fn>int <a name="leftMargin"></a>QScrollView::leftMargin () const<tt> [protected]</tt>
638</h3>
639Returns the left margin.
640<p> <p>See also <a href="#setMargins">setMargins</a>().
641
642<h3 class=fn>void <a name="moveChild"></a>QScrollView::moveChild ( <a href="qwidget.html">QWidget</a>&nbsp;*&nbsp;child, int&nbsp;x, int&nbsp;y )<tt> [virtual]</tt>
643</h3>
644Repositions the <em>child</em> widget to (<em>x</em>, <em>y</em>). This function is
645the same as <a href="#addChild">addChild</a>().
646
647<h3 class=fn>void <a name="removeChild"></a>QScrollView::removeChild ( <a href="qwidget.html">QWidget</a>&nbsp;*&nbsp;child )
648</h3>
649Removes the <em>child</em> widget from the scrolled area. Note that this
650happens automatically if the <em>child</em> is deleted.
651
652<h3 class=fn>void <a name="repaintContents"></a>QScrollView::repaintContents ( int&nbsp;x, int&nbsp;y, int&nbsp;w, int&nbsp;h, bool&nbsp;erase = TRUE )
653</h3>
654Calls <a href="qwidget.html#repaint">repaint</a>() on a rectangle defined by <em>x</em>, <em>y</em>, <em>w</em>, <em>h</em>,
655translated appropriately. If the rectangle is not visible, nothing
656is repainted. If <em>erase</em> is TRUE the background is cleared using
657the background color.
658<p> <p>See also <a href="#updateContents">updateContents</a>().
659
660<h3 class=fn>void <a name="repaintContents-2"></a>QScrollView::repaintContents ( const&nbsp;<a href="qrect.html">QRect</a>&nbsp;&amp;&nbsp;r, bool&nbsp;erase = TRUE )
661</h3>
662This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
663<p> Repaints the contents of rectangle <em>r</em>. If <em>erase</em> is TRUE the
664background is cleared using the background color.
665
666<h3 class=fn>void <a name="repaintContents-3"></a>QScrollView::repaintContents ( bool&nbsp;erase = TRUE )
667</h3>
668This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
669<p> Repaints the contents. If <em>erase</em> is TRUE the background is
670cleared using the background color.
671
672<h3 class=fn>void <a name="resizeContents"></a>QScrollView::resizeContents ( int&nbsp;w, int&nbsp;h )<tt> [virtual slot]</tt>
673</h3>
674Sets the size of the contents area to <em>w</em> pixels wide and <em>h</em>
675pixels high and updates the viewport accordingly.
676
677<h3 class=fn><a href="qscrollview.html#ResizePolicy-enum">ResizePolicy</a> <a name="resizePolicy"></a>QScrollView::resizePolicy () const
678</h3><p>Returns the resize policy.
679See the <a href="qscrollview.html#resizePolicy-prop">"resizePolicy"</a> property for details.
680<h3 class=fn>int <a name="rightMargin"></a>QScrollView::rightMargin () const<tt> [protected]</tt>
681</h3>
682Returns the right margin.
683<p> <p>See also <a href="#setMargins">setMargins</a>().
684
685<h3 class=fn>void <a name="scrollBy"></a>QScrollView::scrollBy ( int&nbsp;dx, int&nbsp;dy )<tt> [slot]</tt>
686</h3>
687Scrolls the content by <em>dx</em> to the left and <em>dy</em> upwards.
688
689<h3 class=fn>void <a name="setContentsPos"></a>QScrollView::setContentsPos ( int&nbsp;x, int&nbsp;y )<tt> [virtual slot]</tt>
690</h3>
691Scrolls the content so that the point <em>(x, y)</em> is in the top-left
692corner.
693
694<p>Example: <a href="process-example.html#x102">process/process.cpp</a>.
695<h3 class=fn>void <a name="setCornerWidget"></a>QScrollView::setCornerWidget ( <a href="qwidget.html">QWidget</a>&nbsp;*&nbsp;corner )<tt> [virtual]</tt>
696</h3>
697Sets the widget in the <em>corner</em> between the two scroll bars.
698<p> You will probably also want to set at least one of the scroll bar
699modes to <a href="#ScrollBarMode-enum">AlwaysOn</a>.
700<p> Passing 0 shows no widget in the corner.
701<p> Any previous <em>corner</em> widget is hidden.
702<p> You may call <a href="#setCornerWidget">setCornerWidget</a>() with the same widget at different
703times.
704<p> All widgets set here will be deleted by the QScrollView when it is
705destroyed unless you separately reparent the widget after setting
706some other corner widget (or 0).
707<p> Any <em>newly</em> set widget should have no current parent.
708<p> By default, no corner widget is present.
709<p> <p>See also <a href="#vScrollBarMode-prop">vScrollBarMode</a> and <a href="#hScrollBarMode-prop">hScrollBarMode</a>.
710
711<p>Example: <a href="scrollview-example.html#x651">scrollview/scrollview.cpp</a>.
712<h3 class=fn>void <a name="setDragAutoScroll"></a>QScrollView::setDragAutoScroll ( bool&nbsp;b )<tt> [virtual]</tt>
713</h3><p>Sets whether autoscrolling in drag move events is enabled to <em>b</em>.
714See the <a href="qscrollview.html#dragAutoScroll-prop">"dragAutoScroll"</a> property for details.
715<h3 class=fn>void <a name="setHBarGeometry"></a>QScrollView::setHBarGeometry ( <a href="qscrollbar.html">QScrollBar</a>&nbsp;&amp;&nbsp;hbar, int&nbsp;x, int&nbsp;y, int&nbsp;w, int&nbsp;h )<tt> [virtual protected]</tt>
716</h3>
717Called when the horizontal scroll bar geometry changes. This is
718provided as a protected function so that subclasses can do
719interesting things such as providing extra buttons in some of the
720space normally used by the scroll bars.
721<p> The default implementation simply gives all the space to <em>hbar</em>.
722The new geometry is given by <em>x</em>, <em>y</em>, <em>w</em> and <em>h</em>.
723<p> <p>See also <a href="#setVBarGeometry">setVBarGeometry</a>().
724
725<h3 class=fn>void <a name="setHScrollBarMode"></a>QScrollView::setHScrollBarMode ( <a href="qscrollview.html#ScrollBarMode-enum">ScrollBarMode</a> )<tt> [virtual]</tt>
726</h3><p>Sets the mode for the horizontal scroll bar.
727See the <a href="qscrollview.html#hScrollBarMode-prop">"hScrollBarMode"</a> property for details.
728<h3 class=fn>void <a name="setMargins"></a>QScrollView::setMargins ( int&nbsp;left, int&nbsp;top, int&nbsp;right, int&nbsp;bottom )<tt> [virtual protected]</tt>
729</h3>
730Sets the margins around the scrolling area to <em>left</em>, <em>top</em>, <em>right</em> and <em>bottom</em>. This is useful for applications such as
731spreadsheets with "locked" rows and columns. The marginal space is
732<em>inside</em> the <a href="qframe.html#frameRect">frameRect</a>() and is left blank; reimplement
733<a href="qframe.html#drawFrame">drawFrame</a>() or put widgets in the unused area.
734<p> By default all margins are zero.
735<p> <p>See also <a href="qframe.html#frameChanged">frameChanged</a>().
736
737<h3 class=fn>void <a name="setResizePolicy"></a>QScrollView::setResizePolicy ( <a href="qscrollview.html#ResizePolicy-enum">ResizePolicy</a> )<tt> [virtual]</tt>
738</h3><p>Sets the resize policy.
739See the <a href="qscrollview.html#resizePolicy-prop">"resizePolicy"</a> property for details.
740<h3 class=fn>void <a name="setStaticBackground"></a>QScrollView::setStaticBackground ( bool&nbsp;y )
741</h3>
742Sets the scrollview to have a static background if <em>y</em> is TRUE,
743or a scrolling background if <em>y</em> is FALSE. By default, the
744background is scrolling.
745<p> Be aware that this mode is quite slow, as a full repaint of the
746visible area has to be triggered on every contents move.
747<p> <p>See also <a href="#hasStaticBackground">hasStaticBackground</a>().
748
749<h3 class=fn>void <a name="setVBarGeometry"></a>QScrollView::setVBarGeometry ( <a href="qscrollbar.html">QScrollBar</a>&nbsp;&amp;&nbsp;vbar, int&nbsp;x, int&nbsp;y, int&nbsp;w, int&nbsp;h )<tt> [virtual protected]</tt>
750</h3>
751Called when the vertical scroll bar geometry changes. This is
752provided as a protected function so that subclasses can do
753interesting things such as providing extra buttons in some of the
754space normally used by the scroll bars.
755<p> The default implementation simply gives all the space to <em>vbar</em>.
756The new geometry is given by <em>x</em>, <em>y</em>, <em>w</em> and <em>h</em>.
757<p> <p>See also <a href="#setHBarGeometry">setHBarGeometry</a>().
758
759<h3 class=fn>void <a name="setVScrollBarMode"></a>QScrollView::setVScrollBarMode ( <a href="qscrollview.html#ScrollBarMode-enum">ScrollBarMode</a> )<tt> [virtual]</tt>
760</h3><p>Sets the mode for the vertical scroll bar.
761See the <a href="qscrollview.html#vScrollBarMode-prop">"vScrollBarMode"</a> property for details.
762<h3 class=fn>void <a name="showChild"></a>QScrollView::showChild ( <a href="qwidget.html">QWidget</a>&nbsp;*&nbsp;child, bool&nbsp;y = TRUE )
763</h3>
764<b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
765<p> Sets the visibility of <em>child</em>. Equivalent to
766<a href="qwidget.html#show">QWidget::show</a>() or <a href="qwidget.html#hide">QWidget::hide</a>().
767
768<h3 class=fn>int <a name="topMargin"></a>QScrollView::topMargin () const<tt> [protected]</tt>
769</h3>
770Returns the top margin.
771<p> <p>See also <a href="#setMargins">setMargins</a>().
772
773<h3 class=fn>void <a name="updateContents"></a>QScrollView::updateContents ( int&nbsp;x, int&nbsp;y, int&nbsp;w, int&nbsp;h )
774</h3>
775Calls <a href="qwidget.html#update">update</a>() on a rectangle defined by <em>x</em>, <em>y</em>, <em>w</em>, <em>h</em>,
776translated appropriately. If the rectangle is not visible, nothing
777is repainted.
778<p> <p>See also <a href="#repaintContents">repaintContents</a>().
779
780<h3 class=fn>void <a name="updateContents-2"></a>QScrollView::updateContents ( const&nbsp;<a href="qrect.html">QRect</a>&nbsp;&amp;&nbsp;r )
781</h3>
782This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
783<p> Updates the contents in rectangle <em>r</em>
784
785<h3 class=fn>void <a name="updateContents-3"></a>QScrollView::updateContents ()
786</h3>
787This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
788<p>
789<h3 class=fn>void <a name="updateScrollBars"></a>QScrollView::updateScrollBars ()<tt> [slot]</tt>
790</h3>
791Updates scroll bars: all possibilities are considered. You should
792never need to call this in your code.
793
794<h3 class=fn><a href="qscrollview.html#ScrollBarMode-enum">ScrollBarMode</a> <a name="vScrollBarMode"></a>QScrollView::vScrollBarMode () const
795</h3><p>Returns the mode for the vertical scroll bar.
796See the <a href="qscrollview.html#vScrollBarMode-prop">"vScrollBarMode"</a> property for details.
797<h3 class=fn><a href="qscrollbar.html">QScrollBar</a>&nbsp;* <a name="verticalScrollBar"></a>QScrollView::verticalScrollBar () const
798</h3>
799Returns the component vertical scroll bar. It is made available to
800allow accelerators, autoscrolling, etc.
801<p> It should not be used for other purposes.
802<p> This function never returns 0.
803
804<h3 class=fn>void <a name="verticalSliderPressed"></a>QScrollView::verticalSliderPressed ()<tt> [signal]</tt>
805</h3>
806
807<p> This signal is emitted whenever the user presses the vertical slider.
808
809<h3 class=fn>void <a name="verticalSliderReleased"></a>QScrollView::verticalSliderReleased ()<tt> [signal]</tt>
810</h3>
811
812<p> This signal is emitted whenever the user releases the vertical slider.
813
814<h3 class=fn><a href="qwidget.html">QWidget</a>&nbsp;* <a name="viewport"></a>QScrollView::viewport () const
815</h3>
816Returns the viewport widget of the scrollview. This is the widget
817containing the contents widget or which is the drawing area.
818
819<p>Examples: <a href="helpsystem-example.html#x2683">helpsystem/tooltip.cpp</a> and <a href="scrollview-example.html#x655">scrollview/scrollview.cpp</a>.
820<h3 class=fn>void <a name="viewportPaintEvent"></a>QScrollView::viewportPaintEvent ( <a href="qpaintevent.html">QPaintEvent</a>&nbsp;*&nbsp;pe )<tt> [virtual protected]</tt>
821</h3>
822This is a low-level painting routine that draws the viewport
823contents. Reimplement this if <a href="#drawContents">drawContents</a>() is too high-level
824(for example, if you don't want to open a <a href="qpainter.html">QPainter</a> on the
825viewport). The paint event is passed in <em>pe</em>.
826
827<h3 class=fn>void <a name="viewportResizeEvent"></a>QScrollView::viewportResizeEvent ( <a href="qresizeevent.html">QResizeEvent</a>&nbsp;* )<tt> [virtual protected]</tt>
828</h3>
829To provide simple processing of events on the contents, this
830function receives all resize events sent to the viewport.
831<p> <p>See also <a href="qwidget.html#resizeEvent">QWidget::resizeEvent</a>().
832
833<p>Example: <a href="tutorial2-06.html#x2587">chart/canvasview.cpp</a>.
834<h3 class=fn><a href="qsize.html">QSize</a> <a name="viewportSize"></a>QScrollView::viewportSize ( int&nbsp;x, int&nbsp;y ) const
835</h3>
836Returns the viewport size for size (<em>x</em>, <em>y</em>).
837<p> The viewport size depends on <em>(x, y)</em> (the size of the contents),
838the size of this widget and the modes of the horizontal and
839vertical scroll bars.
840<p> This function permits widgets that can trade vertical and
841horizontal space for each other to control scroll bar appearance
842better. For example, a word processor or web browser can control
843the width of the right margin accurately, whether or not there
844needs to be a vertical scroll bar.
845
846<h3 class=fn>void <a name="viewportToContents"></a>QScrollView::viewportToContents ( int&nbsp;vx, int&nbsp;vy, int&nbsp;&amp;&nbsp;x, int&nbsp;&amp;&nbsp;y ) const
847</h3>
848Translates a point (<em>vx</em>, <em>vy</em>) on the <a href="#viewport">viewport</a>() widget to a
849point (<em>x</em>, <em>y</em>) in the contents.
850
851<h3 class=fn><a href="qpoint.html">QPoint</a> <a name="viewportToContents-2"></a>QScrollView::viewportToContents ( const&nbsp;<a href="qpoint.html">QPoint</a>&nbsp;&amp;&nbsp;vp ) const
852</h3>
853This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
854<p> Returns the point on the viewport <em>vp</em> translated to a point in
855the contents.
856
857<h3 class=fn>int <a name="visibleHeight"></a>QScrollView::visibleHeight () const
858</h3><p>Returns the vertical amount of the content that is visible.
859See the <a href="qscrollview.html#visibleHeight-prop">"visibleHeight"</a> property for details.
860<h3 class=fn>int <a name="visibleWidth"></a>QScrollView::visibleWidth () const
861</h3><p>Returns the horizontal amount of the content that is visible.
862See the <a href="qscrollview.html#visibleWidth-prop">"visibleWidth"</a> property for details.
863<hr><h2>Property Documentation</h2>
864<h3 class=fn>int <a name="contentsHeight-prop"></a>contentsHeight</h3>
865<p>This property holds the height of the contents area.
866<p>
867<p>Get this property's value with <a href="#contentsHeight">contentsHeight</a>().
868<h3 class=fn>int <a name="contentsWidth-prop"></a>contentsWidth</h3>
869<p>This property holds the width of the contents area.
870<p>
871<p>Get this property's value with <a href="#contentsWidth">contentsWidth</a>().
872<h3 class=fn>int <a name="contentsX-prop"></a>contentsX</h3>
873<p>This property holds the X coordinate of the contents that are at the left edge of the viewport.
874<p>
875<p>Get this property's value with <a href="#contentsX">contentsX</a>().
876<h3 class=fn>int <a name="contentsY-prop"></a>contentsY</h3>
877<p>This property holds the Y coordinate of the contents that are at the top edge of the viewport.
878<p>
879<p>Get this property's value with <a href="#contentsY">contentsY</a>().
880<h3 class=fn>bool <a name="dragAutoScroll-prop"></a>dragAutoScroll</h3>
881<p>This property holds whether autoscrolling in drag move events is enabled.
882<p>If this property is set to TRUE (the default), the QScrollView
883automatically scrolls the contents in drag move events if the user
884moves the cursor close to a border of the view. Of course this
885works only if the viewport accepts drops. Specifying FALSE
886disables this autoscroll feature.
887<p> <b>Warning:</b> Enabling this property might not be enough to
888effectively turn on autoscrolling. If you put a custom widget in
889the QScrollView, you might need to call QDragEvent::ignore() on
890the event in the <a href="qwidget.html#dragEnterEvent">dragEnterEvent</a>() and <a href="qwidget.html#dragMoveEvent">dragMoveEvent</a>()
891reimplementations.
892
893<p>Set this property's value with <a href="#setDragAutoScroll">setDragAutoScroll</a>() and get this property's value with <a href="#dragAutoScroll">dragAutoScroll</a>().
894<h3 class=fn><a href="qscrollview.html#ScrollBarMode-enum">ScrollBarMode</a> <a name="hScrollBarMode-prop"></a>hScrollBarMode</h3>
895<p>This property holds the mode for the horizontal scroll bar.
896<p>The default mode is <a href="#ScrollBarMode-enum">QScrollView::Auto</a>.
897<p> <p>See also <a href="#vScrollBarMode-prop">vScrollBarMode</a>.
898
899<p>Set this property's value with <a href="#setHScrollBarMode">setHScrollBarMode</a>() and get this property's value with <a href="#hScrollBarMode">hScrollBarMode</a>().
900<h3 class=fn><a href="qscrollview.html#ResizePolicy-enum">ResizePolicy</a> <a name="resizePolicy-prop"></a>resizePolicy</h3>
901<p>This property holds the resize policy.
902<p>The default is <a href="#ResizePolicy-enum">Default</a>.
903<p> <p>See also <a href="#ResizePolicy-enum">ResizePolicy</a>.
904
905<p>Set this property's value with <a href="#setResizePolicy">setResizePolicy</a>() and get this property's value with <a href="#resizePolicy">resizePolicy</a>().
906<h3 class=fn><a href="qscrollview.html#ScrollBarMode-enum">ScrollBarMode</a> <a name="vScrollBarMode-prop"></a>vScrollBarMode</h3>
907<p>This property holds the mode for the vertical scroll bar.
908<p>The default mode is <a href="#ScrollBarMode-enum">QScrollView::Auto</a>.
909<p> <p>See also <a href="#hScrollBarMode-prop">hScrollBarMode</a>.
910
911<p>Set this property's value with <a href="#setVScrollBarMode">setVScrollBarMode</a>() and get this property's value with <a href="#vScrollBarMode">vScrollBarMode</a>().
912<h3 class=fn>int <a name="visibleHeight-prop"></a>visibleHeight</h3>
913<p>This property holds the vertical amount of the content that is visible.
914<p>
915<p>Get this property's value with <a href="#visibleHeight">visibleHeight</a>().
916<h3 class=fn>int <a name="visibleWidth-prop"></a>visibleWidth</h3>
917<p>This property holds the horizontal amount of the content that is visible.
918<p>
919<p>Get this property's value with <a href="#visibleWidth">visibleWidth</a>().
920<!-- eof -->
921<hr><p>
922This file is part of the <a href="index.html">Qt toolkit</a>.
923Copyright &copy; 1995-2007
924<a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
925<table width=100% cellspacing=0 border=0><tr>
926<td>Copyright &copy; 2007
927<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
928<td align=right><div align=right>Qt 3.3.8</div>
929</table></div></address></body>
930</html>
Note: See TracBrowser for help on using the repository browser.