Sophie

Sophie

distrib > Mandriva > current > i586 > media > main-updates > by-pkgid > 8e6051afcdb111a0317a58fb64c2abf5 > files > 4797

qt4-doc-4.6.3-0.2mdv2010.2.i586.rpm

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!-- qscrollarea.cpp -->
<head>
  <title>Qt 4.6: QScrollArea Class Reference</title>
  <link href="classic.css" rel="stylesheet" type="text/css" />
</head>
<body>
<a name="//apple_ref/cpp/cl//QScrollArea"></a>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="left" valign="top" width="32"><a href="http://qt.nokia.com/"><img src="images/qt-logo.png" align="left" border="0" /></a></td>
<td width="1">&nbsp;&nbsp;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&nbsp;&middot; <a href="classes.html"><font color="#004faf">All&nbsp;Classes</font></a>&nbsp;&middot; <a href="functions.html"><font color="#004faf">All&nbsp;Functions</font></a>&nbsp;&middot; <a href="overviews.html"><font color="#004faf">Overviews</font></a></td></tr></table><h1 class="title">QScrollArea Class Reference<br /><span class="small-subtitle">[<a href="qtgui.html">QtGui</a> module]</span>
</h1>
<p>The QScrollArea class provides a scrolling view onto another widget. <a href="#details">More...</a></p>
<pre> #include &lt;QScrollArea&gt;</pre><p>Inherits <a href="qabstractscrollarea.html">QAbstractScrollArea</a>.</p>
<ul>
<li><a href="qscrollarea-members.html">List of all members, including inherited members</a></li>
</ul>
<hr />
<a name="properties"></a>
<h2>Properties</h2>
<ul>
<li><div class="fn"><b><a href="qscrollarea.html#alignment-prop">alignment</a></b> : Qt::Alignment</div></li>
<li><div class="fn"><b><a href="qscrollarea.html#widgetResizable-prop">widgetResizable</a></b> : bool</div></li>
</ul>
<ul>
<li><div bar="2" class="fn"></div>2 properties inherited from <a href="qabstractscrollarea.html#properties">QAbstractScrollArea</a></li>
<li><div bar="2" class="fn"></div>6 properties inherited from <a href="qframe.html#properties">QFrame</a></li>
<li><div bar="2" class="fn"></div>58 properties inherited from <a href="qwidget.html#properties">QWidget</a></li>
<li><div bar="2" class="fn"></div>1 property inherited from <a href="qobject.html#properties">QObject</a></li>
</ul>
<hr />
<a name="public-functions"></a>
<h2>Public Functions</h2>
<table class="alignedsummary" border="0" cellpadding="0" cellspacing="0" width="100%">
<tr><td class="memItemLeft" align="right" valign="top"></td><td class="memItemRight" valign="bottom"><b><a href="qscrollarea.html#QScrollArea">QScrollArea</a></b> ( QWidget * <i>parent</i> = 0 )</td></tr>
<tr><td class="memItemLeft" align="right" valign="top"></td><td class="memItemRight" valign="bottom"><b><a href="qscrollarea.html#dtor.QScrollArea">~QScrollArea</a></b> ()</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">Qt::Alignment </td><td class="memItemRight" valign="bottom"><b><a href="qscrollarea.html#alignment-prop">alignment</a></b> () const</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><b><a href="qscrollarea.html#ensureVisible">ensureVisible</a></b> ( int <i>x</i>, int <i>y</i>, int <i>xmargin</i> = 50, int <i>ymargin</i> = 50 )</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><b><a href="qscrollarea.html#ensureWidgetVisible">ensureWidgetVisible</a></b> ( QWidget * <i>childWidget</i>, int <i>xmargin</i> = 50, int <i>ymargin</i> = 50 )</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><b><a href="qscrollarea.html#alignment-prop">setAlignment</a></b> ( Qt::Alignment )</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><b><a href="qscrollarea.html#setWidget">setWidget</a></b> ( QWidget * <i>widget</i> )</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><b><a href="qscrollarea.html#widgetResizable-prop">setWidgetResizable</a></b> ( bool <i>resizable</i> )</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">QWidget * </td><td class="memItemRight" valign="bottom"><b><a href="qscrollarea.html#takeWidget">takeWidget</a></b> ()</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">QWidget * </td><td class="memItemRight" valign="bottom"><b><a href="qscrollarea.html#widget">widget</a></b> () const</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><b><a href="qscrollarea.html#widgetResizable-prop">widgetResizable</a></b> () const</td></tr>
</table>
<hr />
<a name="reimplemented-public-functions"></a>
<h2>Reimplemented Public Functions</h2>
<table class="alignedsummary" border="0" cellpadding="0" cellspacing="0" width="100%">
<tr><td class="memItemLeft" align="right" valign="top">virtual bool </td><td class="memItemRight" valign="bottom"><b><a href="qscrollarea.html#focusNextPrevChild">focusNextPrevChild</a></b> ( bool <i>next</i> )</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">virtual QSize </td><td class="memItemRight" valign="bottom"><b><a href="qscrollarea.html#sizeHint">sizeHint</a></b> () const</td></tr>
</table>
<ul>
<li><div bar="2" class="fn"></div>17 public functions inherited from <a href="qabstractscrollarea.html#public-functions">QAbstractScrollArea</a></li>
<li><div bar="2" class="fn"></div>14 public functions inherited from <a href="qframe.html#public-functions">QFrame</a></li>
<li><div bar="2" class="fn"></div>217 public functions inherited from <a href="qwidget.html#public-functions">QWidget</a></li>
<li><div bar="2" class="fn"></div>29 public functions inherited from <a href="qobject.html#public-functions">QObject</a></li>
<li><div bar="2" class="fn"></div>13 public functions inherited from <a href="qpaintdevice.html#public-functions">QPaintDevice</a></li>
</ul>
<hr />
<a name="reimplemented-protected-functions"></a>
<h2>Reimplemented Protected Functions</h2>
<table class="alignedsummary" border="0" cellpadding="0" cellspacing="0" width="100%">
<tr><td class="memItemLeft" align="right" valign="top">virtual bool </td><td class="memItemRight" valign="bottom"><b><a href="qscrollarea.html#event">event</a></b> ( QEvent * <i>e</i> )</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">virtual bool </td><td class="memItemRight" valign="bottom"><b><a href="qscrollarea.html#eventFilter">eventFilter</a></b> ( QObject * <i>o</i>, QEvent * <i>e</i> )</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">virtual void </td><td class="memItemRight" valign="bottom"><b><a href="qscrollarea.html#resizeEvent">resizeEvent</a></b> ( QResizeEvent * )</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">virtual void </td><td class="memItemRight" valign="bottom"><b><a href="qscrollarea.html#scrollContentsBy">scrollContentsBy</a></b> ( int <i>dx</i>, int <i>dy</i> )</td></tr>
</table>
<ul>
<li><div bar="2" class="fn"></div>18 protected functions inherited from <a href="qabstractscrollarea.html#protected-functions">QAbstractScrollArea</a></li>
<li><div bar="2" class="fn"></div>3 protected functions inherited from <a href="qframe.html#protected-functions">QFrame</a></li>
<li><div bar="2" class="fn"></div>37 protected functions inherited from <a href="qwidget.html#protected-functions">QWidget</a></li>
<li><div bar="2" class="fn"></div>7 protected functions inherited from <a href="qobject.html#protected-functions">QObject</a></li>
<li><div bar="2" class="fn"></div>1 protected function inherited from <a href="qpaintdevice.html#protected-functions">QPaintDevice</a></li>
</ul>
<h3>Additional Inherited Members</h3>
<ul>
<li><div class="fn"></div>19 public slots inherited from <a href="qwidget.html#public-slots">QWidget</a></li>
<li><div class="fn"></div>1 public slot inherited from <a href="qobject.html#public-slots">QObject</a></li>
<li><div class="fn"></div>1 signal inherited from <a href="qwidget.html#signals">QWidget</a></li>
<li><div class="fn"></div>1 signal inherited from <a href="qobject.html#signals">QObject</a></li>
<li><div class="fn"></div>4 static public members inherited from <a href="qwidget.html#static-public-members">QWidget</a></li>
<li><div class="fn"></div>5 static public members inherited from <a href="qobject.html#static-public-members">QObject</a></li>
<li><div class="fn"></div>18 protected functions inherited from <a href="qabstractscrollarea.html#protected-functions">QAbstractScrollArea</a></li>
<li><div class="fn"></div>3 protected functions inherited from <a href="qframe.html#protected-functions">QFrame</a></li>
<li><div class="fn"></div>37 protected functions inherited from <a href="qwidget.html#protected-functions">QWidget</a></li>
<li><div class="fn"></div>7 protected functions inherited from <a href="qobject.html#protected-functions">QObject</a></li>
<li><div class="fn"></div>1 protected function inherited from <a href="qpaintdevice.html#protected-functions">QPaintDevice</a></li>
<li><div class="fn"></div>1 protected slot inherited from <a href="qabstractscrollarea.html#protected-slots">QAbstractScrollArea</a></li>
<li><div class="fn"></div>1 protected slot inherited from <a href="qwidget.html#protected-slots">QWidget</a></li>
</ul>
<a name="details"></a>
<hr />
<h2>Detailed Description</h2>
<p>The QScrollArea class provides a scrolling view onto another widget.</p>
<p>A scroll area is used to display the contents of a child widget within a frame. If the widget exceeds the size of the frame, the view can provide scroll bars so that the entire area of the child widget can be viewed. The child widget must be specified with <a href="qscrollarea.html#setWidget">setWidget</a>(). For example:</p>
<pre> QLabel *imageLabel = new QLabel;
 QImage image(&quot;happyguy.png&quot;);
 imageLabel-&gt;setPixmap(QPixmap::fromImage(image));

 scrollArea = new QScrollArea;
 scrollArea-&gt;setBackgroundRole(QPalette::Dark);
 scrollArea-&gt;setWidget(imageLabel);</pre>
<p>The code above creates a scroll area (shown in the images below) containing an image label. When scaling the image, the scroll area can provide the necessary scroll bars:</p>
<p><table class="generic" align="center" cellpadding="2" cellspacing="1" border="0">
<tr valign="top" class="odd"><td><img src="images/qscrollarea-noscrollbars.png" /></td><td><img src="images/qscrollarea-onescrollbar.png" /></td><td><img src="images/qscrollarea-twoscrollbars.png" /></td></tr>
</table></p>
<p>The scroll bars appearance depends on the currently set <a href="qt.html#ScrollBarPolicy-enum">scroll bar policies</a>. You can control the appearance of the scroll bars using the inherited functionality from <a href="qabstractscrollarea.html">QAbstractScrollArea</a>.</p>
<p>For example, you can set the <a href="qabstractscrollarea.html#horizontalScrollBarPolicy-prop">QAbstractScrollArea::horizontalScrollBarPolicy</a> and <a href="qabstractscrollarea.html#verticalScrollBarPolicy-prop">QAbstractScrollArea::verticalScrollBarPolicy</a> properties. Or if you want the scroll bars to adjust dynamically when the contents of the scroll area changes, you can use the <a href="qabstractscrollarea.html#horizontalScrollBar">horizontalScrollBar()</a> and <a href="qabstractscrollarea.html#verticalScrollBar">verticalScrollBar()</a> functions (which enable you to access the scroll bars) and set the scroll bars' values whenever the scroll area's contents change, using the <a href="qabstractslider.html#value-prop">QScrollBar::setValue</a>() function.</p>
<p>You can retrieve the child widget using the <a href="qscrollarea.html#widget">widget</a>() function. The view can be made to be resizable with the <a href="qscrollarea.html#widgetResizable-prop">setWidgetResizable</a>() function. The alignment of the widget can be specified with <a href="qscrollarea.html#alignment-prop">setAlignment</a>().</p>
<p>Two convenience functions <a href="qscrollarea.html#ensureVisible">ensureVisible</a>() and <a href="qscrollarea.html#ensureWidgetVisible">ensureWidgetVisible</a>() ensure a certain region of the contents is visible inside the viewport, by scrolling the contents if necessary.</p>
<a name="size-hints-and-layouts"></a>
<h3>Size Hints and Layouts</h3>
<p>When using a scroll area to display the contents of a custom widget, it is important to ensure that the <a href="qwidget.html#sizeHint-prop">size hint</a> of the child widget is set to a suitable value. If a standard <a href="qwidget.html">QWidget</a> is used for the child widget, it may be necessary to call <a href="qwidget.html#minimumSize-prop">QWidget::setMinimumSize</a>() to ensure that the contents of the widget are shown correctly within the scroll area.</p>
<p>If a scroll area is used to display the contents of a widget that contains child widgets arranged in a layout, it is important to realise that the size policy of the layout will also determine the size of the widget. This is especially useful to know if you intend to dynamically change the contents of the layout. In such cases, setting the layout's <a href="qlayout.html#sizeConstraint-prop">size constraint</a> property to one which provides constraints on the minimum and/or maximum size of the layout (e.g&#x2e;, <a href="qlayout.html#SizeConstraint-enum">QLayout::SetMinAndMaxSize</a>) will cause the size of the scroll area to be updated whenever the contents of the layout changes.</p>
<p>For a complete example using the QScrollArea class, see the <a href="widgets-imageviewer.html">Image Viewer</a> example. The example shows how to combine <a href="qlabel.html">QLabel</a> and QScrollArea to display an image.</p>
<p>See also <a href="qabstractscrollarea.html">QAbstractScrollArea</a>, <a href="qscrollbar.html">QScrollBar</a>, and <a href="widgets-imageviewer.html">Image Viewer Example</a>.</p>
<hr />
<h2>Property Documentation</h2>
<a name="//apple_ref/cpp/instm/QScrollArea/alignment"></a>
<a name="//apple_ref/cpp/instm/QScrollArea/setAlignment"></a>
<h3 class="fn"><a name="alignment-prop"></a>alignment : <a href="qt.html#AlignmentFlag-enum">Qt::Alignment</a></h3>
<p>This property holds the alignment of the scroll area's widget.</p>
<p>By default, the widget stays rooted to the top-left corner of the scroll area.</p>
<p>This property was introduced in Qt 4.2.</p>
<p><b>Access functions:</b></p>
<table class="alignedsummary" border="0" cellpadding="0" cellspacing="0" width="100%">
<tr><td class="memItemLeft" align="right" valign="top">Qt::Alignment </td><td class="memItemRight" valign="bottom"><b>alignment</b> () const</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><b>setAlignment</b> ( Qt::Alignment )</td></tr>
</table>
<a name="//apple_ref/cpp/instm/QScrollArea/widgetResizable"></a>
<a name="//apple_ref/cpp/instm/QScrollArea/setWidgetResizable"></a>
<h3 class="fn"><a name="widgetResizable-prop"></a>widgetResizable : bool</h3>
<p>This property holds whether the scroll area should resize the view widget.</p>
<p>If this property is set to false (the default), the scroll area honors the size of its widget. Regardless of this property, you can programmatically resize the widget using <a href="qscrollarea.html#widget">widget</a>()-&gt;<a href="qwidget.html#size-prop">resize</a>(), and the scroll area will automatically adjust itself to the new size.</p>
<p>If this property is set to true, the scroll area will automatically resize the widget in order to avoid scroll bars where they can be avoided, or to take advantage of extra space.</p>
<p><b>Access functions:</b></p>
<table class="alignedsummary" border="0" cellpadding="0" cellspacing="0" width="100%">
<tr><td class="memItemLeft" align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><b>widgetResizable</b> () const</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><b>setWidgetResizable</b> ( bool <i>resizable</i> )</td></tr>
</table>
<hr />
<h2>Member Function Documentation</h2>
<a name="//apple_ref/cpp/instm/QScrollArea/QScrollArea"></a>
<h3 class="fn"><a name="QScrollArea"></a>QScrollArea::QScrollArea ( <a href="qwidget.html">QWidget</a> * <i>parent</i> = 0 )</h3>
<p>Constructs an empty scroll area with the given <i>parent</i>.</p>
<p>See also <a href="qscrollarea.html#setWidget">setWidget</a>().</p>
<a name="//apple_ref/cpp/instm/QScrollArea/~QScrollArea"></a>
<h3 class="fn"><a name="dtor.QScrollArea"></a>QScrollArea::~QScrollArea ()</h3>
<p>Destroys the scroll area and its child widget.</p>
<p>See also <a href="qscrollarea.html#setWidget">setWidget</a>().</p>
<a name="//apple_ref/cpp/instm/QScrollArea/ensureVisible"></a>
<h3 class="fn"><a name="ensureVisible"></a>void QScrollArea::ensureVisible ( int <i>x</i>, int <i>y</i>, int <i>xmargin</i> = 50, int <i>ymargin</i> = 50 )</h3>
<p>Scrolls the contents of the scroll area so that the point (<i>x</i>, <i>y</i>) is visible inside the region of the viewport with margins specified in pixels by <i>xmargin</i> and <i>ymargin</i>. If the specified point cannot be reached, the contents are scrolled to the nearest valid position. The default value for both margins is 50 pixels.</p>
<a name="//apple_ref/cpp/instm/QScrollArea/ensureWidgetVisible"></a>
<h3 class="fn"><a name="ensureWidgetVisible"></a>void QScrollArea::ensureWidgetVisible ( <a href="qwidget.html">QWidget</a> * <i>childWidget</i>, int <i>xmargin</i> = 50, int <i>ymargin</i> = 50 )</h3>
<p>Scrolls the contents of the scroll area so that the <i>childWidget</i> of <a href="qscrollarea.html#widget">QScrollArea::widget</a>() is visible inside the viewport with margins specified in pixels by <i>xmargin</i> and <i>ymargin</i>. If the specified point cannot be reached, the contents are scrolled to the nearest valid position. The default value for both margins is 50 pixels.</p>
<p>This function was introduced in Qt 4.2.</p>
<a name="//apple_ref/cpp/instm/QScrollArea/event"></a>
<h3 class="fn"><a name="event"></a>bool QScrollArea::event ( <a href="qevent.html">QEvent</a> * <i>e</i> )&nbsp;&nbsp;<tt> [virtual protected]</tt></h3>
<p>Reimplemented from <a href="qobject.html#event">QObject::event</a>().</p>
<a name="//apple_ref/cpp/instm/QScrollArea/eventFilter"></a>
<h3 class="fn"><a name="eventFilter"></a>bool QScrollArea::eventFilter ( <a href="qobject.html">QObject</a> * <i>o</i>, <a href="qevent.html">QEvent</a> * <i>e</i> )&nbsp;&nbsp;<tt> [virtual protected]</tt></h3>
<p>Reimplemented from <a href="qobject.html#eventFilter">QObject::eventFilter</a>().</p>
<a name="//apple_ref/cpp/instm/QScrollArea/focusNextPrevChild"></a>
<h3 class="fn"><a name="focusNextPrevChild"></a>bool QScrollArea::focusNextPrevChild ( bool <i>next</i> )&nbsp;&nbsp;<tt> [virtual]</tt></h3>
<p>Reimplemented from <a href="qwidget.html#focusNextPrevChild">QWidget::focusNextPrevChild</a>().</p>
<a name="//apple_ref/cpp/instm/QScrollArea/resizeEvent"></a>
<h3 class="fn"><a name="resizeEvent"></a>void QScrollArea::resizeEvent ( <a href="qresizeevent.html">QResizeEvent</a> * )&nbsp;&nbsp;<tt> [virtual protected]</tt></h3>
<p>Reimplemented from <a href="qwidget.html#resizeEvent">QWidget::resizeEvent</a>().</p>
<a name="//apple_ref/cpp/instm/QScrollArea/scrollContentsBy"></a>
<h3 class="fn"><a name="scrollContentsBy"></a>void QScrollArea::scrollContentsBy ( int <i>dx</i>, int <i>dy</i> )&nbsp;&nbsp;<tt> [virtual protected]</tt></h3>
<p>Reimplemented from <a href="qabstractscrollarea.html#scrollContentsBy">QAbstractScrollArea::scrollContentsBy</a>().</p>
<a name="//apple_ref/cpp/instm/QScrollArea/setWidget"></a>
<h3 class="fn"><a name="setWidget"></a>void QScrollArea::setWidget ( <a href="qwidget.html">QWidget</a> * <i>widget</i> )</h3>
<p>Sets the scroll area's <i>widget</i>.</p>
<p>The <i>widget</i> becomes a child of the scroll area, and will be destroyed when the scroll area is deleted or when a new widget is set.</p>
<p>The widget's <a href="qwidget.html#autoFillBackground-prop">autoFillBackground</a> property will be set to <tt>true</tt>.</p>
<p>If the scroll area is visible when the <i>widget</i> is added, you must <a href="qwidget.html#show">show()</a> it explicitly.</p>
<p>Note that You must add the layout of <i>widget</i> before you call this function; if you add it later, the <i>widget</i> will not be visible - regardless of when you <a href="qwidget.html#show">show()</a> the scroll area. In this case, you can also not <a href="qwidget.html#show">show()</a> the <i>widget</i> later.</p>
<p>See also <a href="qscrollarea.html#widget">widget</a>().</p>
<a name="//apple_ref/cpp/instm/QScrollArea/sizeHint"></a>
<h3 class="fn"><a name="sizeHint"></a><a href="qsize.html">QSize</a> QScrollArea::sizeHint () const&nbsp;&nbsp;<tt> [virtual]</tt></h3>
<p>Reimplemented from <a href="qwidget.html#sizeHint-prop">QWidget::sizeHint</a>().</p>
<a name="//apple_ref/cpp/instm/QScrollArea/takeWidget"></a>
<h3 class="fn"><a name="takeWidget"></a><a href="qwidget.html">QWidget</a> * QScrollArea::takeWidget ()</h3>
<p>Removes the scroll area's widget, and passes ownership of the widget to the caller.</p>
<p>See also <a href="qscrollarea.html#widget">widget</a>().</p>
<a name="//apple_ref/cpp/instm/QScrollArea/widget"></a>
<h3 class="fn"><a name="widget"></a><a href="qwidget.html">QWidget</a> * QScrollArea::widget () const</h3>
<p>Returns the scroll area's widget, or 0 if there is none.</p>
<p>See also <a href="qscrollarea.html#setWidget">setWidget</a>().</p>
<p /><address><hr /><div align="center">
<table width="100%" cellspacing="0" border="0"><tr class="address">
<td width="40%" align="left">Copyright &copy; 2010 Nokia Corporation and/or its subsidiary(-ies)</td>
<td width="20%" align="center"><a href="trademarks.html">Trademarks</a></td>
<td width="40%" align="right"><div align="right">Qt 4.6.3</div></td>
</tr></table></div></address></body>
</html>