File: qrubberband.html

package info (click to toggle)
python-qt4 4.9.3-4
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 34,432 kB
  • sloc: python: 34,126; cpp: 11,938; xml: 290; makefile: 223; php: 27
file content (149 lines) | stat: -rw-r--r-- 13,274 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
<?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="index.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;<i>parent</i>&#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#initStyleOption">initStyleOption</a></b> (<i>self</i>, QStyleOptionRubberBand&#160;<i>option</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 class="cpp">
 <span class="type">void</span> Widget<span class="operator">.</span><a href="qwidget.html#mousePressEvent">mousePressEvent</a>(<span class="type"><a href="qmouseevent.html">QMouseEvent</a></span> <span class="operator">*</span>event)
 {
     origin <span class="operator">=</span> event<span class="operator">-</span><span class="operator">&gt;</span>pos();
     <span class="keyword">if</span> (<span class="operator">!</span>rubberBand)
         rubberBand <span class="operator">=</span> <span class="keyword">new</span> <span class="type">QRubberBand</span>(<span class="type">QRubberBand</span><span class="operator">.</span>Rectangle<span class="operator">,</span> <span class="keyword">this</span>);
     rubberBand<span class="operator">-</span><span class="operator">&gt;</span>setGeometry(<span class="type"><a href="qrect.html">QRect</a></span>(origin<span class="operator">,</span> <span class="type"><a href="qsize.html">QSize</a></span>()));
     rubberBand<span class="operator">-</span><span class="operator">&gt;</span>show();
 }

 <span class="type">void</span> Widget<span class="operator">.</span><a href="qwidget.html#mouseMoveEvent">mouseMoveEvent</a>(<span class="type"><a href="qmouseevent.html">QMouseEvent</a></span> <span class="operator">*</span>event)
 {
     rubberBand<span class="operator">-</span><span class="operator">&gt;</span>setGeometry(<span class="type"><a href="qrect.html">QRect</a></span>(origin<span class="operator">,</span> event<span class="operator">-</span><span class="operator">&gt;</span>pos())<span class="operator">.</span>normalized());
 }

 <span class="type">void</span> Widget<span class="operator">.</span><a href="qwidget.html#mouseReleaseEvent">mouseReleaseEvent</a>(<span class="type"><a href="qmouseevent.html">QMouseEvent</a></span> <span class="operator">*</span>event)
 {
     rubberBand<span class="operator">-</span><span class="operator">&gt;</span>hide();
     <span class="comment">// determine selection, for example using QRect.intersects()</span>
     <span class="comment">// and QRect.contains().</span>
 }
</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 class="valuelist">
<tr class="odd" valign="top">
<th class="tblConst">Constant</th>
<th class="tblval">Value</th>
<th class="tbldscr">Description</th>
</tr>
<tr>
<td class="topAlign"><tt>QRubberBand.Line</tt></td>
<td class="topAlign"><tt>0</tt></td>
<td class="topAlign">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 class="topAlign"><tt>QRubberBand.Rectangle</tt></td>
<td class="topAlign"><tt>1</tt></td>
<td class="topAlign">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>
<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;<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 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><p>Reimplemented from <a href="qwidget.html#changeEvent">QWidget.changeEvent</a>().</p>


<h3 class="fn"><a name="event" />bool QRubberBand.event (<i>self</i>, <a href="qevent.html">QEvent</a>&#160;<i>e</i>)</h3><p>Reimplemented from <a href="qobject.html#event">QObject.event</a>().</p>


<h3 class="fn"><a name="initStyleOption" />QRubberBand.initStyleOption (<i>self</i>, <a href="qstyleoptionrubberband.html">QStyleOptionRubberBand</a>&#160;<i>option</i>)</h3><p>Initialize <i>option</i> with the values from this <a href="qrubberband.html">QRubberBand</a>. This method is useful for
subclasses when they need a <a href="qstyleoptionrubberband.html">QStyleOptionRubberBand</a>, but don't
want to fill in all the information themselves.</p>
<p><b>See also</b> <a href="qstyleoption.html#initFrom">QStyleOption.initFrom</a>().</p>


<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><b>See also</b> <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 function.</p>
<p>Moves the rubberband to point <i>p</i>.</p>
<p><b>See also</b> <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><p>Reimplemented from <a href="qwidget.html#moveEvent">QWidget.moveEvent</a>().</p>


<h3 class="fn"><a name="paintEvent" />QRubberBand.paintEvent (<i>self</i>, <a href="qpaintevent.html">QPaintEvent</a>)</h3><p>Reimplemented from <a href="qwidget.html#paintEvent">QWidget.paintEvent</a>().</p>


<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><b>See also</b> <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 function.</p>
<p>Resizes the rubberband so that its new size is <i>size</i>.</p>
<p><b>See also</b> <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><p>Reimplemented from <a href="qwidget.html#resizeEvent">QWidget.resizeEvent</a>().</p>


<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><b>See also</b> <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 function.</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><p>Reimplemented from <a href="qwidget.html#showEvent">QWidget.showEvent</a>().</p>
<address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td align="left" width="25%">PyQt&#160;4.9.3 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.qtsoftware.com">Nokia</a> 2012</td><td align="right" width="25%">Qt&#160;4.8.2</td></tr></table></div></address></body></html>