1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
---|
2 | <!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/src/canvas/qcanvas.cpp:1843 -->
|
---|
3 | <html>
|
---|
4 | <head>
|
---|
5 | <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
---|
6 | <title>QCanvasItem Class</title>
|
---|
7 | <style type="text/css"><!--
|
---|
8 | fn { margin-left: 1cm; text-indent: -1cm; }
|
---|
9 | a:link { color: #004faf; text-decoration: none }
|
---|
10 | a:visited { color: #672967; text-decoration: none }
|
---|
11 | body { background: #ffffff; color: black; }
|
---|
12 | --></style>
|
---|
13 | </head>
|
---|
14 | <body>
|
---|
15 |
|
---|
16 | <table border="0" cellpadding="0" cellspacing="0" width="100%">
|
---|
17 | <tr bgcolor="#E5E5E5">
|
---|
18 | <td valign=center>
|
---|
19 | <a href="index.html">
|
---|
20 | <font color="#004faf">Home</font></a>
|
---|
21 | | <a href="classes.html">
|
---|
22 | <font color="#004faf">All Classes</font></a>
|
---|
23 | | <a href="mainclasses.html">
|
---|
24 | <font color="#004faf">Main Classes</font></a>
|
---|
25 | | <a href="annotated.html">
|
---|
26 | <font color="#004faf">Annotated</font></a>
|
---|
27 | | <a href="groups.html">
|
---|
28 | <font color="#004faf">Grouped Classes</font></a>
|
---|
29 | | <a href="functions.html">
|
---|
30 | <font color="#004faf">Functions</font></a>
|
---|
31 | </td>
|
---|
32 | <td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>QCanvasItem Class Reference<br><small>[<a href="canvas.html">canvas module</a>]</small></h1>
|
---|
33 |
|
---|
34 | <p>The QCanvasItem class provides an abstract graphic object on a QCanvas.
|
---|
35 | <a href="#details">More...</a>
|
---|
36 | <p><tt>#include <<a href="qcanvas-h.html">qcanvas.h</a>></tt>
|
---|
37 | <p>Inherits <a href="qt.html">Qt</a>.
|
---|
38 | <p>Inherited by <a href="qcanvassprite.html">QCanvasSprite</a>, <a href="qcanvaspolygonalitem.html">QCanvasPolygonalItem</a>, and <a href="qcanvastext.html">QCanvasText</a>.
|
---|
39 | <p><a href="qcanvasitem-members.html">List of all member functions.</a>
|
---|
40 | <h2>Public Members</h2>
|
---|
41 | <ul>
|
---|
42 | <li class=fn><a href="#QCanvasItem"><b>QCanvasItem</b></a> ( QCanvas * canvas )</li>
|
---|
43 | <li class=fn>virtual <a href="#~QCanvasItem"><b>~QCanvasItem</b></a> ()</li>
|
---|
44 | <li class=fn>double <a href="#x"><b>x</b></a> () const</li>
|
---|
45 | <li class=fn>double <a href="#y"><b>y</b></a> () const</li>
|
---|
46 | <li class=fn>double <a href="#z"><b>z</b></a> () const</li>
|
---|
47 | <li class=fn>virtual void <a href="#moveBy"><b>moveBy</b></a> ( double dx, double dy )</li>
|
---|
48 | <li class=fn>void <a href="#move"><b>move</b></a> ( double x, double y )</li>
|
---|
49 | <li class=fn>void <a href="#setX"><b>setX</b></a> ( double x )</li>
|
---|
50 | <li class=fn>void <a href="#setY"><b>setY</b></a> ( double y )</li>
|
---|
51 | <li class=fn>void <a href="#setZ"><b>setZ</b></a> ( double z )</li>
|
---|
52 | <li class=fn>bool <a href="#animated"><b>animated</b></a> () const</li>
|
---|
53 | <li class=fn>virtual void <a href="#setAnimated"><b>setAnimated</b></a> ( bool y )</li>
|
---|
54 | <li class=fn>virtual void <a href="#setVelocity"><b>setVelocity</b></a> ( double vx, double vy )</li>
|
---|
55 | <li class=fn>void <a href="#setXVelocity"><b>setXVelocity</b></a> ( double vx )</li>
|
---|
56 | <li class=fn>void <a href="#setYVelocity"><b>setYVelocity</b></a> ( double vy )</li>
|
---|
57 | <li class=fn>double <a href="#xVelocity"><b>xVelocity</b></a> () const</li>
|
---|
58 | <li class=fn>double <a href="#yVelocity"><b>yVelocity</b></a> () const</li>
|
---|
59 | <li class=fn>virtual void <a href="#advance"><b>advance</b></a> ( int phase )</li>
|
---|
60 | <li class=fn>virtual bool <a href="#collidesWith"><b>collidesWith</b></a> ( const QCanvasItem * other ) const = 0</li>
|
---|
61 | <li class=fn>QCanvasItemList <a href="#collisions"><b>collisions</b></a> ( bool exact ) const</li>
|
---|
62 | <li class=fn>virtual void <a href="#setCanvas"><b>setCanvas</b></a> ( QCanvas * c )</li>
|
---|
63 | <li class=fn>virtual void <a href="#draw"><b>draw</b></a> ( QPainter & painter ) = 0</li>
|
---|
64 | <li class=fn>void <a href="#show"><b>show</b></a> ()</li>
|
---|
65 | <li class=fn>void <a href="#hide"><b>hide</b></a> ()</li>
|
---|
66 | <li class=fn>virtual void <a href="#setVisible"><b>setVisible</b></a> ( bool yes )</li>
|
---|
67 | <li class=fn>bool <a href="#isVisible"><b>isVisible</b></a> () const</li>
|
---|
68 | <li class=fn>virtual void <a href="#setSelected"><b>setSelected</b></a> ( bool yes )</li>
|
---|
69 | <li class=fn>bool <a href="#isSelected"><b>isSelected</b></a> () const</li>
|
---|
70 | <li class=fn>virtual void <a href="#setEnabled"><b>setEnabled</b></a> ( bool yes )</li>
|
---|
71 | <li class=fn>bool <a href="#isEnabled"><b>isEnabled</b></a> () const</li>
|
---|
72 | <li class=fn>virtual void <a href="#setActive"><b>setActive</b></a> ( bool yes )</li>
|
---|
73 | <li class=fn>bool <a href="#isActive"><b>isActive</b></a> () const</li>
|
---|
74 | <li class=fn>bool visible () const <em>(obsolete)</em></li>
|
---|
75 | <li class=fn>bool selected () const <em>(obsolete)</em></li>
|
---|
76 | <li class=fn>bool enabled () const <em>(obsolete)</em></li>
|
---|
77 | <li class=fn>bool active () const <em>(obsolete)</em></li>
|
---|
78 | <li class=fn>enum <a href="#RttiValues-enum"><b>RttiValues</b></a> { Rtti_Item = 0, Rtti_Sprite = 1, Rtti_PolygonalItem = 2, Rtti_Text = 3, Rtti_Polygon = 4, Rtti_Rectangle = 5, Rtti_Ellipse = 6, Rtti_Line = 7, Rtti_Spline = 8 }</li>
|
---|
79 | <li class=fn>virtual int <a href="#rtti"><b>rtti</b></a> () const</li>
|
---|
80 | <li class=fn>virtual QRect <a href="#boundingRect"><b>boundingRect</b></a> () const = 0</li>
|
---|
81 | <li class=fn>virtual QRect <a href="#boundingRectAdvanced"><b>boundingRectAdvanced</b></a> () const</li>
|
---|
82 | <li class=fn>QCanvas * <a href="#canvas"><b>canvas</b></a> () const</li>
|
---|
83 | </ul>
|
---|
84 | <h2>Protected Members</h2>
|
---|
85 | <ul>
|
---|
86 | <li class=fn>void <a href="#update"><b>update</b></a> ()</li>
|
---|
87 | </ul>
|
---|
88 | <hr><a name="details"></a><h2>Detailed Description</h2>
|
---|
89 |
|
---|
90 |
|
---|
91 | The QCanvasItem class provides an abstract graphic object on a <a href="qcanvas.html">QCanvas</a>.
|
---|
92 |
|
---|
93 | <p>
|
---|
94 |
|
---|
95 |
|
---|
96 | <p> A variety of QCanvasItem subclasses provide immediately usable
|
---|
97 | behaviour. This class is a pure abstract superclass providing the
|
---|
98 | behaviour that is shared among all the concrete canvas item classes.
|
---|
99 | QCanvasItem is not intended for direct subclassing. It is much easier
|
---|
100 | to subclass one of its subclasses, e.g. <a href="qcanvaspolygonalitem.html">QCanvasPolygonalItem</a> (the
|
---|
101 | commonest base class), <a href="qcanvasrectangle.html">QCanvasRectangle</a>, <a href="qcanvassprite.html">QCanvasSprite</a>, <a href="qcanvasellipse.html">QCanvasEllipse</a>
|
---|
102 | or <a href="qcanvastext.html">QCanvasText</a>.
|
---|
103 | <p> Canvas items are added to a canvas by constructing them and passing the
|
---|
104 | canvas to the canvas item's constructor. An item can be moved to a
|
---|
105 | different canvas using <a href="#setCanvas">setCanvas</a>().
|
---|
106 | <p> Items appear on the canvas after their <a href="#show">show()</a>
|
---|
107 | function has been called (or <a href="#setVisible">setVisible(TRUE)</a>), and <em>after</em> <a href="#update">update</a>() has been called. The
|
---|
108 | canvas only shows items that are <a href="#setVisible">visible</a>,
|
---|
109 | and then only if <a href="#update">update</a>() is called. If you created the canvas
|
---|
110 | without passing a width and height to the constructor you'll also need
|
---|
111 | to call <a href="qcanvas.html#resize">resize()</a>. Since the canvas
|
---|
112 | background defaults to white and canvas items default to white,
|
---|
113 | you may need to change colors to see your items.
|
---|
114 | <p> A QCanvasItem object can be moved in the <a href="#x">x</a>(), <a href="#y">y</a>() and <a href="#z">z</a>() dimensions
|
---|
115 | using functions such as <a href="#move">move</a>(), <a href="#moveBy">moveBy</a>(), <a href="#setX">setX</a>(), <a href="#setY">setY</a>() and <a href="#setZ">setZ</a>(). A
|
---|
116 | canvas item can be set in motion, `animated', using <a href="#setAnimated">setAnimated</a>() and
|
---|
117 | given a velocity in the x and y directions with <a href="#setXVelocity">setXVelocity</a>() and
|
---|
118 | <a href="#setYVelocity">setYVelocity</a>() -- the same effect can be achieved by calling
|
---|
119 | <a href="#setVelocity">setVelocity</a>(). Use the <a href="#collidesWith">collidesWith</a>() function to see if the canvas item
|
---|
120 | will collide on the <em>next</em> <a href="#advance">advance</a>(1) and use <a href="#collisions">collisions</a>() to see what
|
---|
121 | collisions have occurred.
|
---|
122 | <p> Use <a href="qcanvassprite.html">QCanvasSprite</a> or your own subclass of QCanvasSprite to create canvas
|
---|
123 | items which are animated, i.e. which change over time.
|
---|
124 | <p> The size of a canvas item is given by <a href="#boundingRect">boundingRect</a>(). Use
|
---|
125 | <a href="#boundingRectAdvanced">boundingRectAdvanced</a>() to see what the size of the canvas item will be
|
---|
126 | <em>after</em> the next advance(1) call.
|
---|
127 | <p> The <a href="#rtti">rtti</a>() function is used for identifying subclasses of QCanvasItem.
|
---|
128 | The <a href="#canvas">canvas</a>() function returns a pointer to the canvas which contains the
|
---|
129 | canvas item.
|
---|
130 | <p> QCanvasItem provides the <a href="#show">show</a>() and <a href="#isVisible">isVisible</a>() functions like those in
|
---|
131 | <a href="qwidget.html">QWidget</a>.
|
---|
132 | <p> QCanvasItem also provides the <a href="#setEnabled">setEnabled</a>(), <a href="#setActive">setActive</a>() and
|
---|
133 | <a href="#setSelected">setSelected</a>() functions; these functions set the relevant boolean and
|
---|
134 | cause a repaint but the boolean values they set are not used in
|
---|
135 | QCanvasItem itself. You can make use of these booleans in your subclasses.
|
---|
136 | <p> By default, canvas items have no velocity, no size, and are not in
|
---|
137 | motion. The subclasses provided in Qt do not change these defaults
|
---|
138 | except where noted.
|
---|
139 | <p> <p>See also <a href="graphics.html">Graphics Classes</a> and <a href="images.html">Image Processing Classes</a>.
|
---|
140 |
|
---|
141 | <hr><h2>Member Type Documentation</h2>
|
---|
142 | <h3 class=fn><a name="RttiValues-enum"></a>QCanvasItem::RttiValues</h3>
|
---|
143 |
|
---|
144 | <p> This enum is used to name the different types of canvas item.
|
---|
145 | <ul>
|
---|
146 | <li><tt>QCanvasItem::Rtti_Item</tt> - Canvas item abstract base class
|
---|
147 | <li><tt>QCanvasItem::Rtti_Ellipse</tt>
|
---|
148 | <li><tt>QCanvasItem::Rtti_Line</tt>
|
---|
149 | <li><tt>QCanvasItem::Rtti_Polygon</tt>
|
---|
150 | <li><tt>QCanvasItem::Rtti_PolygonalItem</tt>
|
---|
151 | <li><tt>QCanvasItem::Rtti_Rectangle</tt>
|
---|
152 | <li><tt>QCanvasItem::Rtti_Spline</tt>
|
---|
153 | <li><tt>QCanvasItem::Rtti_Sprite</tt>
|
---|
154 | <li><tt>QCanvasItem::Rtti_Text</tt>
|
---|
155 | </ul><p>
|
---|
156 | <hr><h2>Member Function Documentation</h2>
|
---|
157 | <h3 class=fn><a name="QCanvasItem"></a>QCanvasItem::QCanvasItem ( <a href="qcanvas.html">QCanvas</a> * canvas )
|
---|
158 | </h3>
|
---|
159 | Constructs a QCanvasItem on canvas <em>canvas</em>.
|
---|
160 | <p> <p>See also <a href="#setCanvas">setCanvas</a>().
|
---|
161 |
|
---|
162 | <h3 class=fn><a name="~QCanvasItem"></a>QCanvasItem::~QCanvasItem ()<tt> [virtual]</tt>
|
---|
163 | </h3>
|
---|
164 | Destroys the QCanvasItem and removes it from its canvas.
|
---|
165 |
|
---|
166 | <h3 class=fn>bool <a name="active"></a>QCanvasItem::active () const
|
---|
167 | </h3>
|
---|
168 | <b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
|
---|
169 | <p>
|
---|
170 | Use <a href="#isActive">isActive</a>() instead.
|
---|
171 |
|
---|
172 | <h3 class=fn>void <a name="advance"></a>QCanvasItem::advance ( int phase )<tt> [virtual]</tt>
|
---|
173 | </h3>
|
---|
174 | The default implementation moves the canvas item, if it is
|
---|
175 | <a href="#animated">animated</a>(), by the preset velocity if <em>phase</em> is 1, and does
|
---|
176 | nothing if <em>phase</em> is 0.
|
---|
177 | <p> Note that if you reimplement this function, the reimplementation
|
---|
178 | must not change the canvas in any way, for example it must not add
|
---|
179 | or remove items.
|
---|
180 | <p> <p>See also <a href="qcanvas.html#advance">QCanvas::advance</a>() and <a href="#setVelocity">setVelocity</a>().
|
---|
181 |
|
---|
182 | <p>Example: <a href="canvas-example.html#x2913">canvas/canvas.cpp</a>.
|
---|
183 | <p>Reimplemented in <a href="qcanvassprite.html#advance">QCanvasSprite</a>.
|
---|
184 | <h3 class=fn>bool <a name="animated"></a>QCanvasItem::animated () const
|
---|
185 | </h3>
|
---|
186 | Returns TRUE if the canvas item is in motion; otherwise returns
|
---|
187 | FALSE.
|
---|
188 | <p> <p>See also <a href="#setVelocity">setVelocity</a>() and <a href="#setAnimated">setAnimated</a>().
|
---|
189 |
|
---|
190 | <h3 class=fn><a href="qrect.html">QRect</a> <a name="boundingRect"></a>QCanvasItem::boundingRect () const<tt> [pure virtual]</tt>
|
---|
191 | </h3>
|
---|
192 |
|
---|
193 | <p> Returns the bounding rectangle in pixels that the canvas item covers.
|
---|
194 | <p> <p>See also <a href="#boundingRectAdvanced">boundingRectAdvanced</a>().
|
---|
195 |
|
---|
196 | <p>Reimplemented in <a href="qcanvassprite.html#boundingRect">QCanvasSprite</a>, <a href="qcanvaspolygonalitem.html#boundingRect">QCanvasPolygonalItem</a>, and <a href="qcanvastext.html#boundingRect">QCanvasText</a>.
|
---|
197 | <h3 class=fn><a href="qrect.html">QRect</a> <a name="boundingRectAdvanced"></a>QCanvasItem::boundingRectAdvanced () const<tt> [virtual]</tt>
|
---|
198 | </h3>
|
---|
199 | Returns the bounding rectangle of pixels that the canvas item <em>will</em> cover after <a href="#advance">advance</a>(1) is called.
|
---|
200 | <p> <p>See also <a href="#boundingRect">boundingRect</a>().
|
---|
201 |
|
---|
202 | <h3 class=fn><a href="qcanvas.html">QCanvas</a> * <a name="canvas"></a>QCanvasItem::canvas () const
|
---|
203 | </h3>
|
---|
204 |
|
---|
205 | <p> Returns the canvas containing the canvas item.
|
---|
206 |
|
---|
207 | <h3 class=fn>bool <a name="collidesWith"></a>QCanvasItem::collidesWith ( const <a href="qcanvasitem.html">QCanvasItem</a> * other ) const<tt> [pure virtual]</tt>
|
---|
208 | </h3>
|
---|
209 |
|
---|
210 | <p> Returns TRUE if the canvas item will collide with the <em>other</em>
|
---|
211 | item <em>after</em> they have moved by their current velocities;
|
---|
212 | otherwise returns FALSE.
|
---|
213 | <p> <p>See also <a href="#collisions">collisions</a>().
|
---|
214 |
|
---|
215 | <p>Example: <a href="canvas-example.html#x2914">canvas/canvas.cpp</a>.
|
---|
216 | <h3 class=fn><a href="qcanvasitemlist.html">QCanvasItemList</a> <a name="collisions"></a>QCanvasItem::collisions ( bool exact ) const
|
---|
217 | </h3>
|
---|
218 | Returns the list of canvas items that this canvas item has
|
---|
219 | collided with.
|
---|
220 | <p> A collision is generally defined as occurring when the pixels of
|
---|
221 | one item draw on the pixels of another item, but not all
|
---|
222 | subclasses are so precise. Also, since pixel-wise collision
|
---|
223 | detection can be slow, this function works in either exact or
|
---|
224 | inexact mode, according to the <em>exact</em> parameter.
|
---|
225 | <p> If <em>exact</em> is TRUE, the canvas items returned have been
|
---|
226 | accurately tested for collision with the canvas item.
|
---|
227 | <p> If <em>exact</em> is FALSE, the canvas items returned are <em>near</em> the
|
---|
228 | canvas item. You can test the canvas items returned using
|
---|
229 | <a href="#collidesWith">collidesWith</a>() if any are interesting collision candidates. By
|
---|
230 | using this approach, you can ignore some canvas items for which
|
---|
231 | collisions are not relevant.
|
---|
232 | <p> The returned list is a list of QCanvasItems, but often you will
|
---|
233 | need to cast the items to their subclass types. The safe way to do
|
---|
234 | this is to use <a href="#rtti">rtti</a>() before casting. This provides some of the
|
---|
235 | functionality of the standard C++ dynamic cast operation even on
|
---|
236 | compilers where dynamic casts are not available.
|
---|
237 | <p> Note that a canvas item may be `on' a canvas, e.g. it was created
|
---|
238 | with the canvas as parameter, even though its coordinates place it
|
---|
239 | beyond the edge of the canvas's area. Collision detection only
|
---|
240 | works for canvas items which are wholly or partly within the
|
---|
241 | canvas's area.
|
---|
242 | <p> Note that if items have a velocity (see <a href="#setVelocity">setVelocity</a>()), then
|
---|
243 | collision testing is done based on where the item <em>will</em> be when
|
---|
244 | it moves, not its current location. For example, a "ball" item
|
---|
245 | doesn't need to actually embed into a "wall" item before a
|
---|
246 | collision is detected. For items without velocity, plain
|
---|
247 | intersection is used.
|
---|
248 |
|
---|
249 | <h3 class=fn>void <a name="draw"></a>QCanvasItem::draw ( <a href="qpainter.html">QPainter</a> & painter )<tt> [pure virtual]</tt>
|
---|
250 | </h3>
|
---|
251 |
|
---|
252 | <p> This abstract virtual function draws the canvas item using <em>painter</em>.
|
---|
253 | <p> <b>Warning:</b> When you reimplement this function, make sure that you
|
---|
254 | leave the painter in the same state as you found it. For example,
|
---|
255 | if you start by calling <a href="qpainter.html#translate">QPainter::translate</a>(50, 50), end your
|
---|
256 | code by calling QPainter::translate(-50, -50). Be also aware that
|
---|
257 | the painter might already have some transformations set (i.e.,
|
---|
258 | don't call <a href="qpainter.html#resetXForm">QPainter::resetXForm</a>() when you're done).
|
---|
259 |
|
---|
260 | <p>Reimplemented in <a href="qcanvassprite.html#draw">QCanvasSprite</a>, <a href="qcanvaspolygonalitem.html#draw">QCanvasPolygonalItem</a>, and <a href="qcanvastext.html#draw">QCanvasText</a>.
|
---|
261 | <h3 class=fn>bool <a name="enabled"></a>QCanvasItem::enabled () const
|
---|
262 | </h3>
|
---|
263 | <b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
|
---|
264 | <p>
|
---|
265 | Use <a href="#isEnabled">isEnabled</a>() instead.
|
---|
266 |
|
---|
267 | <h3 class=fn>void <a name="hide"></a>QCanvasItem::hide ()
|
---|
268 | </h3> Shorthand for <a href="#setVisible">setVisible</a>(FALSE).
|
---|
269 | <h3 class=fn>bool <a name="isActive"></a>QCanvasItem::isActive () const
|
---|
270 | </h3>
|
---|
271 |
|
---|
272 | <p> Returns TRUE if the QCanvasItem is active; otherwise returns FALSE.
|
---|
273 |
|
---|
274 | <h3 class=fn>bool <a name="isEnabled"></a>QCanvasItem::isEnabled () const
|
---|
275 | </h3>
|
---|
276 |
|
---|
277 | <p> Returns TRUE if the QCanvasItem is enabled; otherwise returns FALSE.
|
---|
278 |
|
---|
279 | <h3 class=fn>bool <a name="isSelected"></a>QCanvasItem::isSelected () const
|
---|
280 | </h3>
|
---|
281 |
|
---|
282 | <p> Returns TRUE if the canvas item is selected; otherwise returns FALSE.
|
---|
283 |
|
---|
284 | <h3 class=fn>bool <a name="isVisible"></a>QCanvasItem::isVisible () const
|
---|
285 | </h3>
|
---|
286 |
|
---|
287 | <p> Returns TRUE if the canvas item is visible; otherwise returns
|
---|
288 | FALSE.
|
---|
289 | <p> Note that in this context TRUE does <em>not</em> mean that the canvas
|
---|
290 | item is currently in a view, merely that if a view is showing the
|
---|
291 | area where the canvas item is positioned, and the item is not
|
---|
292 | obscured by items with higher z values, and the view is not
|
---|
293 | obscured by overlaying windows, it would be visible.
|
---|
294 | <p> <p>See also <a href="#setVisible">setVisible</a>() and <a href="#z">z</a>().
|
---|
295 |
|
---|
296 | <h3 class=fn>void <a name="move"></a>QCanvasItem::move ( double x, double y )
|
---|
297 | </h3>
|
---|
298 | Moves the canvas item to the absolute position (<em>x</em>, <em>y</em>).
|
---|
299 |
|
---|
300 | <p>Example: <a href="canvas-example.html#x2915">canvas/canvas.cpp</a>.
|
---|
301 | <h3 class=fn>void <a name="moveBy"></a>QCanvasItem::moveBy ( double dx, double dy )<tt> [virtual]</tt>
|
---|
302 | </h3>
|
---|
303 | Moves the canvas item relative to its current position by (<em>dx</em>,
|
---|
304 | <em>dy</em>).
|
---|
305 |
|
---|
306 | <p>Example: <a href="canvas-example.html#x2916">canvas/canvas.cpp</a>.
|
---|
307 | <h3 class=fn>int <a name="rtti"></a>QCanvasItem::rtti () const<tt> [virtual]</tt>
|
---|
308 | </h3>
|
---|
309 | Returns 0 (QCanvasItem::Rtti_Item).
|
---|
310 | <p> Make your derived classes return their own values for <a href="#rtti">rtti</a>(), so
|
---|
311 | that you can distinguish between objects returned by
|
---|
312 | QCanvas::at(). You should use values greater than 1000 to allow
|
---|
313 | for extensions to this class.
|
---|
314 | <p> Overuse of this functionality can damage it's extensibility. For
|
---|
315 | example, once you have identified a base class of a QCanvasItem
|
---|
316 | found by QCanvas::at(), cast it to that type and call meaningful
|
---|
317 | methods rather than acting upon the object based on its rtti
|
---|
318 | value.
|
---|
319 | <p> For example:
|
---|
320 | <p> <pre>
|
---|
321 | QCanvasItem* item;
|
---|
322 | // Find an item, e.g. with QCanvasItem::collisions().
|
---|
323 | ...
|
---|
324 | if (item-><a href="#rtti">rtti</a>() == MySprite::RTTI ) {
|
---|
325 | MySprite* s = (MySprite*)item;
|
---|
326 | if (s->isDamagable()) s->loseHitPoints(1000);
|
---|
327 | if (s->isHot()) myself->loseHitPoints(1000);
|
---|
328 | ...
|
---|
329 | }
|
---|
330 | </pre>
|
---|
331 |
|
---|
332 |
|
---|
333 | <p>Example: <a href="canvas-example.html#x2917">canvas/canvas.cpp</a>.
|
---|
334 | <p>Reimplemented in <a href="qcanvassprite.html#rtti">QCanvasSprite</a>, <a href="qcanvaspolygonalitem.html#rtti">QCanvasPolygonalItem</a>, and <a href="qcanvastext.html#rtti">QCanvasText</a>.
|
---|
335 | <h3 class=fn>bool <a name="selected"></a>QCanvasItem::selected () const
|
---|
336 | </h3>
|
---|
337 | <b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
|
---|
338 | <p>
|
---|
339 | Use <a href="#isSelected">isSelected</a>() instead.
|
---|
340 |
|
---|
341 | <h3 class=fn>void <a name="setActive"></a>QCanvasItem::setActive ( bool yes )<tt> [virtual]</tt>
|
---|
342 | </h3>
|
---|
343 | Sets the active flag of the item to <em>yes</em>. If this changes the
|
---|
344 | item's active state the item will be redrawn when
|
---|
345 | <a href="qcanvas.html#update">QCanvas::update</a>() is next called.
|
---|
346 | <p> The <a href="qcanvas.html">QCanvas</a>, QCanvasItem and the Qt-supplied QCanvasItem
|
---|
347 | subclasses do not make use of this value. The <a href="#setActive">setActive</a>() function
|
---|
348 | is supplied because many applications need it, but it is up to you
|
---|
349 | how you use the <a href="#isActive">isActive</a>() value.
|
---|
350 |
|
---|
351 | <h3 class=fn>void <a name="setAnimated"></a>QCanvasItem::setAnimated ( bool y )<tt> [virtual]</tt>
|
---|
352 | </h3>
|
---|
353 | Sets the canvas item to be in motion if <em>y</em> is TRUE, or not if <em>y</em> is FALSE. The speed and direction of the motion is set with
|
---|
354 | <a href="#setVelocity">setVelocity</a>(), or with <a href="#setXVelocity">setXVelocity</a>() and <a href="#setYVelocity">setYVelocity</a>().
|
---|
355 | <p> <p>See also <a href="#advance">advance</a>() and <a href="qcanvas.html#advance">QCanvas::advance</a>().
|
---|
356 |
|
---|
357 | <h3 class=fn>void <a name="setCanvas"></a>QCanvasItem::setCanvas ( <a href="qcanvas.html">QCanvas</a> * c )<tt> [virtual]</tt>
|
---|
358 | </h3>
|
---|
359 | Sets the <a href="qcanvas.html">QCanvas</a> upon which the canvas item is to be drawn to <em>c</em>.
|
---|
360 | <p> <p>See also <a href="#canvas">canvas</a>().
|
---|
361 |
|
---|
362 | <h3 class=fn>void <a name="setEnabled"></a>QCanvasItem::setEnabled ( bool yes )<tt> [virtual]</tt>
|
---|
363 | </h3>
|
---|
364 | Sets the enabled flag of the item to <em>yes</em>. If this changes the
|
---|
365 | item's enabled state the item will be redrawn when
|
---|
366 | <a href="qcanvas.html#update">QCanvas::update</a>() is next called.
|
---|
367 | <p> The <a href="qcanvas.html">QCanvas</a>, QCanvasItem and the Qt-supplied QCanvasItem
|
---|
368 | subclasses do not make use of this value. The <a href="#setEnabled">setEnabled</a>()
|
---|
369 | function is supplied because many applications need it, but it is
|
---|
370 | up to you how you use the <a href="#isEnabled">isEnabled</a>() value.
|
---|
371 |
|
---|
372 | <h3 class=fn>void <a name="setSelected"></a>QCanvasItem::setSelected ( bool yes )<tt> [virtual]</tt>
|
---|
373 | </h3>
|
---|
374 | Sets the selected flag of the item to <em>yes</em>. If this changes the
|
---|
375 | item's selected state the item will be redrawn when
|
---|
376 | <a href="qcanvas.html#update">QCanvas::update</a>() is next called.
|
---|
377 | <p> The <a href="qcanvas.html">QCanvas</a>, QCanvasItem and the Qt-supplied QCanvasItem
|
---|
378 | subclasses do not make use of this value. The <a href="#setSelected">setSelected</a>()
|
---|
379 | function is supplied because many applications need it, but it is
|
---|
380 | up to you how you use the <a href="#isSelected">isSelected</a>() value.
|
---|
381 |
|
---|
382 | <h3 class=fn>void <a name="setVelocity"></a>QCanvasItem::setVelocity ( double vx, double vy )<tt> [virtual]</tt>
|
---|
383 | </h3>
|
---|
384 | Sets the canvas item to be in motion, moving by <em>vx</em> and <em>vy</em>
|
---|
385 | pixels in the horizontal and vertical directions respectively.
|
---|
386 | <p> <p>See also <a href="#advance">advance</a>(), <a href="#setXVelocity">setXVelocity</a>(), and <a href="#setYVelocity">setYVelocity</a>().
|
---|
387 |
|
---|
388 | <h3 class=fn>void <a name="setVisible"></a>QCanvasItem::setVisible ( bool yes )<tt> [virtual]</tt>
|
---|
389 | </h3>
|
---|
390 | Makes the canvas item visible if <em>yes</em> is TRUE, or invisible if
|
---|
391 | <em>yes</em> is FALSE. The change takes effect when <a href="qcanvas.html#update">QCanvas::update</a>() is
|
---|
392 | next called.
|
---|
393 |
|
---|
394 | <h3 class=fn>void <a name="setX"></a>QCanvasItem::setX ( double x )
|
---|
395 | </h3>
|
---|
396 |
|
---|
397 | <p> Moves the canvas item so that its x-position is <em>x</em>.
|
---|
398 | <p> <p>See also <a href="#x">x</a>() and <a href="#move">move</a>().
|
---|
399 |
|
---|
400 | <p>Example: <a href="tutorial2-06.html#x2568">chart/chartform_canvas.cpp</a>.
|
---|
401 | <h3 class=fn>void <a name="setXVelocity"></a>QCanvasItem::setXVelocity ( double vx )
|
---|
402 | </h3>
|
---|
403 |
|
---|
404 | <p> Sets the horizontal component of the canvas item's velocity to <em>vx</em>.
|
---|
405 | <p> <p>See also <a href="#setYVelocity">setYVelocity</a>() and <a href="#setVelocity">setVelocity</a>().
|
---|
406 |
|
---|
407 | <h3 class=fn>void <a name="setY"></a>QCanvasItem::setY ( double y )
|
---|
408 | </h3>
|
---|
409 |
|
---|
410 | <p> Moves the canvas item so that its y-position is <em>y</em>.
|
---|
411 | <p> <p>See also <a href="#y">y</a>() and <a href="#move">move</a>().
|
---|
412 |
|
---|
413 | <p>Example: <a href="tutorial2-06.html#x2569">chart/chartform_canvas.cpp</a>.
|
---|
414 | <h3 class=fn>void <a name="setYVelocity"></a>QCanvasItem::setYVelocity ( double vy )
|
---|
415 | </h3>
|
---|
416 |
|
---|
417 | <p> Sets the vertical component of the canvas item's velocity to <em>vy</em>.
|
---|
418 | <p> <p>See also <a href="#setXVelocity">setXVelocity</a>() and <a href="#setVelocity">setVelocity</a>().
|
---|
419 |
|
---|
420 | <h3 class=fn>void <a name="setZ"></a>QCanvasItem::setZ ( double z )
|
---|
421 | </h3>
|
---|
422 |
|
---|
423 | <p> Sets the z index of the canvas item to <em>z</em>. Higher-z items
|
---|
424 | obscure (are in front of) lower-z items.
|
---|
425 | <p> <p>See also <a href="#z">z</a>() and <a href="#move">move</a>().
|
---|
426 |
|
---|
427 | <p>Examples: <a href="canvas-example.html#x2918">canvas/canvas.cpp</a> and <a href="tutorial2-06.html#x2570">chart/chartform_canvas.cpp</a>.
|
---|
428 | <h3 class=fn>void <a name="show"></a>QCanvasItem::show ()
|
---|
429 | </h3> Shorthand for <a href="#setVisible">setVisible</a>(TRUE).
|
---|
430 | <p>Examples: <a href="canvas-example.html#x2919">canvas/canvas.cpp</a> and <a href="tutorial2-06.html#x2571">chart/chartform_canvas.cpp</a>.
|
---|
431 | <h3 class=fn>void <a name="update"></a>QCanvasItem::update ()<tt> [protected]</tt>
|
---|
432 | </h3>
|
---|
433 |
|
---|
434 | <p> Call this function to repaint the canvas's changed chunks.
|
---|
435 |
|
---|
436 | <h3 class=fn>bool <a name="visible"></a>QCanvasItem::visible () const
|
---|
437 | </h3>
|
---|
438 | <b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
|
---|
439 | <p>
|
---|
440 | Use <a href="#isVisible">isVisible</a>() instead.
|
---|
441 |
|
---|
442 | <h3 class=fn>double <a name="x"></a>QCanvasItem::x () const
|
---|
443 | </h3>
|
---|
444 |
|
---|
445 | <p> Returns the horizontal position of the canvas item. Note that
|
---|
446 | subclasses often have an origin other than the top-left corner.
|
---|
447 |
|
---|
448 | <p>Example: <a href="canvas-example.html#x2920">canvas/canvas.cpp</a>.
|
---|
449 | <h3 class=fn>double <a name="xVelocity"></a>QCanvasItem::xVelocity () const
|
---|
450 | </h3>
|
---|
451 | Returns the horizontal velocity component of the canvas item.
|
---|
452 |
|
---|
453 | <h3 class=fn>double <a name="y"></a>QCanvasItem::y () const
|
---|
454 | </h3>
|
---|
455 |
|
---|
456 | <p> Returns the vertical position of the canvas item. Note that
|
---|
457 | subclasses often have an origin other than the top-left corner.
|
---|
458 |
|
---|
459 | <p>Example: <a href="canvas-example.html#x2921">canvas/canvas.cpp</a>.
|
---|
460 | <h3 class=fn>double <a name="yVelocity"></a>QCanvasItem::yVelocity () const
|
---|
461 | </h3>
|
---|
462 | Returns the vertical velocity component of the canvas item.
|
---|
463 |
|
---|
464 | <h3 class=fn>double <a name="z"></a>QCanvasItem::z () const
|
---|
465 | </h3>
|
---|
466 |
|
---|
467 | <p> Returns the z index of the canvas item, which is used for visual
|
---|
468 | order: higher-z items obscure (are in front of) lower-z items.
|
---|
469 |
|
---|
470 | <!-- eof -->
|
---|
471 | <hr><p>
|
---|
472 | This file is part of the <a href="index.html">Qt toolkit</a>.
|
---|
473 | Copyright © 1995-2007
|
---|
474 | <a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
|
---|
475 | <table width=100% cellspacing=0 border=0><tr>
|
---|
476 | <td>Copyright © 2007
|
---|
477 | <a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
|
---|
478 | <td align=right><div align=right>Qt 3.3.8</div>
|
---|
479 | </table></div></address></body>
|
---|
480 | </html>
|
---|