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