File: qscrollarea.html

package info (click to toggle)
python-qt4 4.0.1-5
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 18,632 kB
  • ctags: 2,639
  • sloc: python: 29,409; sh: 5,646; cpp: 3,168; xml: 149; makefile: 109
file content (60 lines) | stat: -rw-r--r-- 10,228 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html><head><title>QScrollArea Class Reference</title><style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
td.postheader { font-family: sans-serif }
tr.address { font-family: sans-serif }
body { background: #ffffff; color: black; }
</style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr /><td align="left" valign="top" width="32"><img align="left" border="0" height="32" src="images/rb-logo.png" width="32" /></td><td width="1">&#160;&#160;</td><td class="postheader" valign="center"><a href="../pyqt4ref.html"><font color="#004faf">Home</font></a>&#160;&#183; <a href="classes.html"><font color="#004faf">All Classes</font></a>&#160;&#183; <a href="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">QScrollArea Class Reference<br /><sup><sup>[<a href="qtgui.html">QtGui</a> module]</sup></sup></h1><p>The QScrollArea class provides a scrolling view onto another widget. <a href="#details">More...</a></p>
<p>Inherits <a href="qabstractscrollarea.html">QAbstractScrollArea</a>.</p><h3>Methods</h3><ul><li><div class="fn" /><b><a href="qscrollarea.html#QScrollArea">__init__</a></b> (<i>self</i>, QWidget&#160;<i>parent</i>&#160;=&#160;None)</li><li><div class="fn" /><b><a href="qscrollarea.html#ensureVisible">ensureVisible</a></b> (<i>self</i>, int&#160;<i>x</i>, int&#160;<i>y</i>, int&#160;<i>xmargin</i>&#160;=&#160;50, int&#160;<i>ymargin</i>&#160;=&#160;50)</li><li><div class="fn" />bool <b><a href="qscrollarea.html#event">event</a></b> (<i>self</i>, QEvent)</li><li><div class="fn" />bool <b><a href="qscrollarea.html#eventFilter">eventFilter</a></b> (<i>self</i>, QObject, QEvent)</li><li><div class="fn" />bool <b><a href="qscrollarea.html#focusNextPrevChild">focusNextPrevChild</a></b> (<i>self</i>, bool&#160;<i>next</i>)</li><li><div class="fn" /><b><a href="qscrollarea.html#resizeEvent">resizeEvent</a></b> (<i>self</i>, QResizeEvent)</li><li><div class="fn" /><b><a href="qscrollarea.html#scrollContentsBy">scrollContentsBy</a></b> (<i>self</i>, int&#160;<i>dx</i>, int&#160;<i>dy</i>)</li><li><div class="fn" /><b><a href="qscrollarea.html#setWidget">setWidget</a></b> (<i>self</i>, QWidget&#160;<i>w</i>)</li><li><div class="fn" /><b><a href="qscrollarea.html#setWidgetResizable">setWidgetResizable</a></b> (<i>self</i>, bool&#160;<i>resizable</i>)</li><li><div class="fn" />QSize <b><a href="qscrollarea.html#sizeHint">sizeHint</a></b> (<i>self</i>)</li><li><div class="fn" />QWidget <b><a href="qscrollarea.html#takeWidget">takeWidget</a></b> (<i>self</i>)</li><li><div class="fn" />QWidget <b><a href="qscrollarea.html#widget">widget</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qscrollarea.html#widgetResizable">widgetResizable</a></b> (<i>self</i>)</li></ul><a name="details" /><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("happyguy.png");
    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>
<table align="center" border="0" cellpadding="2" cellspacing="1">
<tr bgcolor="#F0F0F0" valign="top">
<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>
<br />
<br />
<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 setAlignment().</p>
<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>For a complete example using the QScrollArea class, see the <a href="widgets-imageviewer.html">ImageViewer example</a>. 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> and <a href="qscrollbar.html">QScrollBar</a>.</p>
<hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QScrollArea" />QScrollArea.__init__ (<i>self</i>, <a href="qwidget.html">QWidget</a>&#160;<i>parent</i>&#160;=&#160;None)</h3><p>The <i>parent</i> argument, if not None, causes <i>self</i> to be owned by Qt instead of PyQt.</p><p>Constructs an empty scroll area with the given <i>parent</i>.</p>
<p>See also <a href="qscrollarea.html#setWidget">setWidget</a>().</p>
<h3 class="fn"><a name="ensureVisible" />QScrollArea.ensureVisible (<i>self</i>, int&#160;<i>x</i>, int&#160;<i>y</i>, int&#160;<i>xmargin</i>&#160;=&#160;50, int&#160;<i>ymargin</i>&#160;=&#160;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>
<p><b>Note:</b> If you call this function before entering an event loop, make sure that you have set the focus on the <a href="qscrollarea.html">QScrollArea</a> widget; otherwise, the viewport will be scrolled back to its old position.</p>
<p>Example:</p>
<pre>
    QScrollArea sa;
    sa.setBackgroundRole(QPalette.Dark);
    sa.setWidget(childWidget);
    sa.show();

    sa.setFocus();
    sa.ensureVisible(640, 480, 10, 10);

    qapp.exec();
</pre>
<h3 class="fn"><a name="event" />bool QScrollArea.event (<i>self</i>, <a href="qevent.html">QEvent</a>)</h3><h3 class="fn"><a name="eventFilter" />bool QScrollArea.eventFilter (<i>self</i>, <a href="qobject.html">QObject</a>, <a href="qevent.html">QEvent</a>)</h3><h3 class="fn"><a name="focusNextPrevChild" />bool QScrollArea.focusNextPrevChild (<i>self</i>, bool&#160;<i>next</i>)</h3><h3 class="fn"><a name="resizeEvent" />QScrollArea.resizeEvent (<i>self</i>, <a href="qresizeevent.html">QResizeEvent</a>)</h3><h3 class="fn"><a name="scrollContentsBy" />QScrollArea.scrollContentsBy (<i>self</i>, int&#160;<i>dx</i>, int&#160;<i>dy</i>)</h3><h3 class="fn"><a name="setWidget" />QScrollArea.setWidget (<i>self</i>, <a href="qwidget.html">QWidget</a>&#160;<i>w</i>)</h3><p>The <i>w</i> argument has it's ownership transferred to Qt.</p><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>See also <a href="qscrollarea.html#widget">widget</a>().</p>
<h3 class="fn"><a name="setWidgetResizable" />QScrollArea.setWidgetResizable (<i>self</i>, bool&#160;<i>resizable</i>)</h3><h3 class="fn"><a name="sizeHint" /><a href="qsize.html">QSize</a> QScrollArea.sizeHint (<i>self</i>)</h3><h3 class="fn"><a name="takeWidget" /><a href="qwidget.html">QWidget</a> QScrollArea.takeWidget (<i>self</i>)</h3><p>The <i>QWidget</i> result</p><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>
<h3 class="fn"><a name="widget" /><a href="qwidget.html">QWidget</a> QScrollArea.widget (<i>self</i>)</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>
<h3 class="fn"><a name="widgetResizable" />bool QScrollArea.widgetResizable (<i>self</i>)</h3><address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td width="25%">PyQt&#160;4.0.1 for X11</td><td align="center" width="50%">Copyright &#169; <a href="http://www.riverbankcomputing.com">Riverbank&#160;Computing&#160;Ltd</a> and <a href="http://www.trolltech.com">Trolltech&#160;AS</a> 2006</td><td align="right" width="25%">Qt&#160;4.1.4</td></tr></table></div></address></body></html>