File: qrubberband.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 (74 lines) | stat: -rw-r--r-- 10,612 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?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>QRubberBand 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">QRubberBand Class Reference<br /><sup><sup>[<a href="qtgui.html">QtGui</a> module]</sup></sup></h1><p>The QRubberBand class provides a rectangle or line that can indicate a selection or a boundary. <a href="#details">More...</a></p>
<p>Inherits <a href="qwidget.html">QWidget</a>.</p><h3>Types</h3><ul><li><div class="fn" />enum <b><a href="qrubberband.html#Shape-enum">Shape</a></b> { Line, Rectangle }</li></ul><h3>Methods</h3><ul><li><div class="fn" /><b><a href="qrubberband.html#QRubberBand">__init__</a></b> (<i>self</i>, Shape, QWidget&#160;=&#160;None)</li><li><div class="fn" /><b><a href="qrubberband.html#changeEvent">changeEvent</a></b> (<i>self</i>, QEvent)</li><li><div class="fn" />bool <b><a href="qrubberband.html#event">event</a></b> (<i>self</i>, QEvent&#160;<i>e</i>)</li><li><div class="fn" /><b><a href="qrubberband.html#move">move</a></b> (<i>self</i>, QPoint&#160;<i>p</i>)</li><li><div class="fn" /><b><a href="qrubberband.html#move-2">move</a></b> (<i>self</i>, int&#160;<i>ax</i>, int&#160;<i>ay</i>)</li><li><div class="fn" /><b><a href="qrubberband.html#moveEvent">moveEvent</a></b> (<i>self</i>, QMoveEvent)</li><li><div class="fn" /><b><a href="qrubberband.html#paintEvent">paintEvent</a></b> (<i>self</i>, QPaintEvent)</li><li><div class="fn" /><b><a href="qrubberband.html#resize">resize</a></b> (<i>self</i>, int&#160;<i>w</i>, int&#160;<i>h</i>)</li><li><div class="fn" /><b><a href="qrubberband.html#resize-2">resize</a></b> (<i>self</i>, QSize&#160;<i>s</i>)</li><li><div class="fn" /><b><a href="qrubberband.html#resizeEvent">resizeEvent</a></b> (<i>self</i>, QResizeEvent)</li><li><div class="fn" /><b><a href="qrubberband.html#setGeometry">setGeometry</a></b> (<i>self</i>, QRect&#160;<i>r</i>)</li><li><div class="fn" /><b><a href="qrubberband.html#setGeometry-2">setGeometry</a></b> (<i>self</i>, int&#160;<i>ax</i>, int&#160;<i>ay</i>, int&#160;<i>aw</i>, int&#160;<i>ah</i>)</li><li><div class="fn" />Shape <b><a href="qrubberband.html#shape">shape</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qrubberband.html#showEvent">showEvent</a></b> (<i>self</i>, QShowEvent)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QRubberBand class provides a rectangle or line that can indicate a selection or a boundary.</p>
<p>A rubber band is often used to show a new bounding area (as in a <a href="qsplitter.html">QSplitter</a> or a <a href="qdockwidget.html">QDockWidget</a> that is undocking). Historically this has been implemented using a <a href="qpainter.html">QPainter</a> and XOR, but this approach doesn't always work properly since rendering can happen in the window below the rubber band, but before the rubber band has been "erased".</p>
<p>You can create a QRubberBand whenever you need to render a rubber band around a given area (or to represent a single line), then call <a href="qrubberband.html#setGeometry">setGeometry</a>(), <a href="qrubberband.html#move">move</a>() or <a href="qrubberband.html#resize">resize</a>() to position and size it. A common pattern is to do this in conjunction with mouse events. For example:</p>
<pre>
    void Widget.mousePressEvent(QMouseEvent *e)
    {
        origin = e-&gt;pos(); // origin is a QPoint
        if (!rubberBand)
            rubberBand = new QRubberBand(QRubberBand.Rectangle, this);
        rubberBand-&gt;setGeometry(QRect(origin, QSize()));
        band-&gt;show();
    }

    void Widget.mouseMoveEvent(QMouseEvent *e)
    {
        band-&gt;setGeometry(QRect(origin, e-&gt;pos()).normalized());
    }

    void Widget.mouseReleaseEvent(QMouseEvent *e)
    {
        band-&gt;hide();
        // determine selection, for example using QRect.intersects()
        // and QRect.contains().
    }
</pre>
<p>If you pass a parent to QRubberBand's constructor, the rubber band will display only inside its parent, but stays on top of other child widgets. If no parent is passed, QRubberBand will act as a top-level widget.</p>
<p>Call <a href="qwidget.html#show">show</a>() to make the rubber band visible; also when the rubber band is not a top-level. Hiding or destroying the widget will make the rubber band disappear. The rubber band can be a <a href="qrubberband.html#Shape-enum">Rectangle</a> or a <a href="qrubberband.html#Shape-enum">Line</a> (vertical or horizontal), depending on the <a href="qrubberband.html#shape">shape</a>() it was given when constructed.</p>
<hr /><h2>Type Documentation</h2><h3 class="fn"><a name="Shape-enum" />QRubberBand.Shape</h3><p>This enum specifies what shape a <a href="qrubberband.html">QRubberBand</a> should have. This is a drawing hint that is passed down to the style system, and can be interpreted by each <a href="qstyle.html">QStyle</a>.</p>
<table border="1" cellpadding="2" cellspacing="1" width="100%">
<tr>
<th width="25%">Constant</th>
<th width="15%">Value</th>
<th width="60%">Description</th>
</tr>
<tr>
<td valign="top"><tt>QRubberBand.Line</tt></td>
<td align="center" valign="top"><tt>0</tt></td>
<td valign="top">A <a href="qrubberband.html">QRubberBand</a> can represent a vertical or horizontal line. Geometry is still given in <a href="qwidget.html#rect-prop">rect</a>() and the line will fill the given geometry on most styles.</td>
</tr>
<tr>
<td valign="top"><tt>QRubberBand.Rectangle</tt></td>
<td align="center" valign="top"><tt>1</tt></td>
<td valign="top">A <a href="qrubberband.html">QRubberBand</a> can represent a rectangle. Some styles will interpret this as a filled (often semi-transparent) rectangle, or a rectangular outline.</td>
</tr>
</table>
<br />
<br />
<hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QRubberBand" />QRubberBand.__init__ (<i>self</i>, <a href="qrubberband.html#Shape-enum">Shape</a>, <a href="qwidget.html">QWidget</a>&#160;=&#160;None)</h3><p>The <i>QWidget</i> argument, if not None, causes <i>self</i> to be owned by Qt instead of PyQt.</p><p>Constructs a rubber band of shape <i>s</i>, with parent <i>p</i>.</p>
<p>By default a rectangular rubber band (<i>s</i> is <tt>Rectangle</tt>) will use a mask, so that a small border of the rectangle is all that is visible. Some styles (e.g., native Mac OS X) will change this and call <a href="qwidget.html#windowOpacity-prop">QWidget.setWindowOpacity</a>() to make a semi-transparent filled selection rectangle.</p>
<h3 class="fn"><a name="changeEvent" />QRubberBand.changeEvent (<i>self</i>, <a href="qevent.html">QEvent</a>)</h3><h3 class="fn"><a name="event" />bool QRubberBand.event (<i>self</i>, <a href="qevent.html">QEvent</a>&#160;<i>e</i>)</h3><h3 class="fn"><a name="move" />QRubberBand.move (<i>self</i>, <a href="qpoint.html">QPoint</a>&#160;<i>p</i>)</h3><p>Moves the rubberband to point (<i>x</i>, <i>y</i>).</p>
<p>See also <a href="qrubberband.html#resize">resize</a>().</p>
<h3 class="fn"><a name="move-2" />QRubberBand.move (<i>self</i>, int&#160;<i>ax</i>, int&#160;<i>ay</i>)</h3><p>This is an overloaded member function, provided for convenience.</p>
<p>Moves the rubberband to point <i>p</i>.</p>
<p>See also <a href="qrubberband.html#resize">resize</a>().</p>
<h3 class="fn"><a name="moveEvent" />QRubberBand.moveEvent (<i>self</i>, <a href="qmoveevent.html">QMoveEvent</a>)</h3><h3 class="fn"><a name="paintEvent" />QRubberBand.paintEvent (<i>self</i>, <a href="qpaintevent.html">QPaintEvent</a>)</h3><h3 class="fn"><a name="resize" />QRubberBand.resize (<i>self</i>, int&#160;<i>w</i>, int&#160;<i>h</i>)</h3><p>Resizes the rubberband so that its width is <i>width</i>, and its height is <i>height</i>.</p>
<p>See also <a href="qrubberband.html#move">move</a>().</p>
<h3 class="fn"><a name="resize-2" />QRubberBand.resize (<i>self</i>, <a href="qsize.html">QSize</a>&#160;<i>s</i>)</h3><p>This is an overloaded member function, provided for convenience.</p>
<p>Resizes the rubberband so that its new size is <i>size</i>.</p>
<p>See also <a href="qrubberband.html#move">move</a>().</p>
<h3 class="fn"><a name="resizeEvent" />QRubberBand.resizeEvent (<i>self</i>, <a href="qresizeevent.html">QResizeEvent</a>)</h3><h3 class="fn"><a name="setGeometry" />QRubberBand.setGeometry (<i>self</i>, <a href="qrect.html">QRect</a>&#160;<i>r</i>)</h3><p>Sets the geometry of the rubber band to <i>rect</i>, specified in the coordinate system of its parent widget.</p>
<p>See also <a href="qwidget.html#geometry-prop">QWidget.geometry</a>.</p>
<h3 class="fn"><a name="setGeometry-2" />QRubberBand.setGeometry (<i>self</i>, int&#160;<i>ax</i>, int&#160;<i>ay</i>, int&#160;<i>aw</i>, int&#160;<i>ah</i>)</h3><p>This is an overloaded member function, provided for convenience.</p>
<p>Sets the geometry of the rubberband to the rectangle whose top-left corner lies at the point (<i>x</i>, <i>y</i>), and with dimensions specified by <i>width</i> and <i>height</i>. The geometry is specified in the parent widget's coordinate system.</p>
<h3 class="fn"><a name="shape" /><a href="qrubberband.html#Shape-enum">Shape</a> QRubberBand.shape (<i>self</i>)</h3><p>Returns the shape of this rubber band. The shape can only be set upon construction.</p>
<h3 class="fn"><a name="showEvent" />QRubberBand.showEvent (<i>self</i>, <a href="qshowevent.html">QShowEvent</a>)</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>