source: trunk/doc/html/qcanvasitem.html@ 208

Last change on this file since 208 was 190, checked in by rudi, 14 years ago

reference documentation added

File size: 26.2 KB
Line 
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"><!--
8fn { margin-left: 1cm; text-indent: -1cm; }
9a:link { color: #004faf; text-decoration: none }
10a:visited { color: #672967; text-decoration: none }
11body { 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&nbsp;Classes</font></a>
23 | <a href="mainclasses.html">
24<font color="#004faf">Main&nbsp;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&nbsp;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 &lt;<a href="qcanvas-h.html">qcanvas.h</a>&gt;</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&nbsp;*&nbsp;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&nbsp;dx, double&nbsp;dy )</li>
48<li class=fn>void <a href="#move"><b>move</b></a> ( double&nbsp;x, double&nbsp;y )</li>
49<li class=fn>void <a href="#setX"><b>setX</b></a> ( double&nbsp;x )</li>
50<li class=fn>void <a href="#setY"><b>setY</b></a> ( double&nbsp;y )</li>
51<li class=fn>void <a href="#setZ"><b>setZ</b></a> ( double&nbsp;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&nbsp;y )</li>
54<li class=fn>virtual void <a href="#setVelocity"><b>setVelocity</b></a> ( double&nbsp;vx, double&nbsp;vy )</li>
55<li class=fn>void <a href="#setXVelocity"><b>setXVelocity</b></a> ( double&nbsp;vx )</li>
56<li class=fn>void <a href="#setYVelocity"><b>setYVelocity</b></a> ( double&nbsp;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&nbsp;phase )</li>
60<li class=fn>virtual bool <a href="#collidesWith"><b>collidesWith</b></a> ( const&nbsp;QCanvasItem&nbsp;*&nbsp;other ) const = 0</li>
61<li class=fn>QCanvasItemList <a href="#collisions"><b>collisions</b></a> ( bool&nbsp;exact ) const</li>
62<li class=fn>virtual void <a href="#setCanvas"><b>setCanvas</b></a> ( QCanvas&nbsp;*&nbsp;c )</li>
63<li class=fn>virtual void <a href="#draw"><b>draw</b></a> ( QPainter&nbsp;&amp;&nbsp;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&nbsp;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&nbsp;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&nbsp;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&nbsp;yes )</li>
73<li class=fn>bool <a href="#isActive"><b>isActive</b></a> () const</li>
74<li class=fn>bool visible () const &nbsp;<em>(obsolete)</em></li>
75<li class=fn>bool selected () const &nbsp;<em>(obsolete)</em></li>
76<li class=fn>bool enabled () const &nbsp;<em>(obsolete)</em></li>
77<li class=fn>bool active () const &nbsp;<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
91The 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
97behaviour. This class is a pure abstract superclass providing the
98behaviour that is shared among all the concrete canvas item classes.
99QCanvasItem is not intended for direct subclassing. It is much easier
100to subclass one of its subclasses, e.g. <a href="qcanvaspolygonalitem.html">QCanvasPolygonalItem</a> (the
101commonest base class), <a href="qcanvasrectangle.html">QCanvasRectangle</a>, <a href="qcanvassprite.html">QCanvasSprite</a>, <a href="qcanvasellipse.html">QCanvasEllipse</a>
102or <a href="qcanvastext.html">QCanvasText</a>.
103<p> Canvas items are added to a canvas by constructing them and passing the
104canvas to the canvas item's constructor. An item can be moved to a
105different canvas using <a href="#setCanvas">setCanvas</a>().
106<p> Items appear on the canvas after their <a href="#show">show()</a>
107function has been called (or <a href="#setVisible">setVisible(TRUE)</a>), and <em>after</em> <a href="#update">update</a>() has been called. The
108canvas only shows items that are <a href="#setVisible">visible</a>,
109and then only if <a href="#update">update</a>() is called. If you created the canvas
110without passing a width and height to the constructor you'll also need
111to call <a href="qcanvas.html#resize">resize()</a>. Since the canvas
112background defaults to white and canvas items default to white,
113you 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
115using 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
116canvas item can be set in motion, `animated', using <a href="#setAnimated">setAnimated</a>() and
117given 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
120will collide on the <em>next</em> <a href="#advance">advance</a>(1) and use <a href="#collisions">collisions</a>() to see what
121collisions have occurred.
122<p> Use <a href="qcanvassprite.html">QCanvasSprite</a> or your own subclass of QCanvasSprite to create canvas
123items 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.
128The <a href="#canvas">canvas</a>() function returns a pointer to the canvas which contains the
129canvas 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
134cause a repaint but the boolean values they set are not used in
135QCanvasItem 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
137motion. The subclasses provided in Qt do not change these defaults
138except 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>&nbsp;*&nbsp;canvas )
158</h3>
159Constructs 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>
164Destroys 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>
170Use <a href="#isActive">isActive</a>() instead.
171
172<h3 class=fn>void <a name="advance"></a>QCanvasItem::advance ( int&nbsp;phase )<tt> [virtual]</tt>
173</h3>
174The 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
176nothing if <em>phase</em> is 0.
177<p> Note that if you reimplement this function, the reimplementation
178must not change the canvas in any way, for example it must not add
179or 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>
186Returns TRUE if the canvas item is in motion; otherwise returns
187FALSE.
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>
199Returns 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>&nbsp;* <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&nbsp;<a href="qcanvasitem.html">QCanvasItem</a>&nbsp;*&nbsp;other ) const<tt> [pure virtual]</tt>
208</h3>
209
210<p> Returns TRUE if the canvas item will collide with the <em>other</em>
211item <em>after</em> they have moved by their current velocities;
212otherwise 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&nbsp;exact ) const
217</h3>
218Returns the list of canvas items that this canvas item has
219collided with.
220<p> A collision is generally defined as occurring when the pixels of
221one item draw on the pixels of another item, but not all
222subclasses are so precise. Also, since pixel-wise collision
223detection can be slow, this function works in either exact or
224inexact mode, according to the <em>exact</em> parameter.
225<p> If <em>exact</em> is TRUE, the canvas items returned have been
226accurately tested for collision with the canvas item.
227<p> If <em>exact</em> is FALSE, the canvas items returned are <em>near</em> the
228canvas item. You can test the canvas items returned using
229<a href="#collidesWith">collidesWith</a>() if any are interesting collision candidates. By
230using this approach, you can ignore some canvas items for which
231collisions are not relevant.
232<p> The returned list is a list of QCanvasItems, but often you will
233need to cast the items to their subclass types. The safe way to do
234this is to use <a href="#rtti">rtti</a>() before casting. This provides some of the
235functionality of the standard C++ dynamic cast operation even on
236compilers where dynamic casts are not available.
237<p> Note that a canvas item may be `on' a canvas, e.g. it was created
238with the canvas as parameter, even though its coordinates place it
239beyond the edge of the canvas's area. Collision detection only
240works for canvas items which are wholly or partly within the
241canvas's area.
242<p> Note that if items have a velocity (see <a href="#setVelocity">setVelocity</a>()), then
243collision testing is done based on where the item <em>will</em> be when
244it moves, not its current location. For example, a "ball" item
245doesn't need to actually embed into a "wall" item before a
246collision is detected. For items without velocity, plain
247intersection is used.
248
249<h3 class=fn>void <a name="draw"></a>QCanvasItem::draw ( <a href="qpainter.html">QPainter</a>&nbsp;&amp;&nbsp;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
254leave the painter in the same state as you found it. For example,
255if you start by calling <a href="qpainter.html#translate">QPainter::translate</a>(50, 50), end your
256code by calling QPainter::translate(-50, -50). Be also aware that
257the painter might already have some transformations set (i.e.,
258don'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>
265Use <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
288FALSE.
289<p> Note that in this context TRUE does <em>not</em> mean that the canvas
290item is currently in a view, merely that if a view is showing the
291area where the canvas item is positioned, and the item is not
292obscured by items with higher z values, and the view is not
293obscured 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&nbsp;x, double&nbsp;y )
297</h3>
298Moves 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&nbsp;dx, double&nbsp;dy )<tt> [virtual]</tt>
302</h3>
303Moves 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>
309Returns 0 (QCanvasItem::Rtti_Item).
310<p> Make your derived classes return their own values for <a href="#rtti">rtti</a>(), so
311that you can distinguish between objects returned by
312QCanvas::at(). You should use values greater than 1000 to allow
313for extensions to this class.
314<p> Overuse of this functionality can damage it's extensibility. For
315example, once you have identified a base class of a QCanvasItem
316found by QCanvas::at(), cast it to that type and call meaningful
317methods rather than acting upon the object based on its rtti
318value.
319<p> For example:
320<p> <pre>
321 QCanvasItem* item;
322 // Find an item, e.g. with QCanvasItem::collisions().
323 ...
324 if (item-&gt;<a href="#rtti">rtti</a>() == MySprite::RTTI ) {
325 MySprite* s = (MySprite*)item;
326 if (s-&gt;isDamagable()) s-&gt;loseHitPoints(1000);
327 if (s-&gt;isHot()) myself-&gt;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>
339Use <a href="#isSelected">isSelected</a>() instead.
340
341<h3 class=fn>void <a name="setActive"></a>QCanvasItem::setActive ( bool&nbsp;yes )<tt> [virtual]</tt>
342</h3>
343Sets the active flag of the item to <em>yes</em>. If this changes the
344item'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
347subclasses do not make use of this value. The <a href="#setActive">setActive</a>() function
348is supplied because many applications need it, but it is up to you
349how you use the <a href="#isActive">isActive</a>() value.
350
351<h3 class=fn>void <a name="setAnimated"></a>QCanvasItem::setAnimated ( bool&nbsp;y )<tt> [virtual]</tt>
352</h3>
353Sets 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>&nbsp;*&nbsp;c )<tt> [virtual]</tt>
358</h3>
359Sets 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&nbsp;yes )<tt> [virtual]</tt>
363</h3>
364Sets the enabled flag of the item to <em>yes</em>. If this changes the
365item'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
368subclasses do not make use of this value. The <a href="#setEnabled">setEnabled</a>()
369function is supplied because many applications need it, but it is
370up 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&nbsp;yes )<tt> [virtual]</tt>
373</h3>
374Sets the selected flag of the item to <em>yes</em>. If this changes the
375item'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
378subclasses do not make use of this value. The <a href="#setSelected">setSelected</a>()
379function is supplied because many applications need it, but it is
380up 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&nbsp;vx, double&nbsp;vy )<tt> [virtual]</tt>
383</h3>
384Sets the canvas item to be in motion, moving by <em>vx</em> and <em>vy</em>
385pixels 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&nbsp;yes )<tt> [virtual]</tt>
389</h3>
390Makes 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
392next called.
393
394<h3 class=fn>void <a name="setX"></a>QCanvasItem::setX ( double&nbsp;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&nbsp;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&nbsp;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&nbsp;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&nbsp;z )
421</h3>
422
423<p> Sets the z index of the canvas item to <em>z</em>. Higher-z items
424obscure (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>
440Use <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
446subclasses 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>
451Returns 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
457subclasses 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>
462Returns 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
468order: higher-z items obscure (are in front of) lower-z items.
469
470<!-- eof -->
471<hr><p>
472This file is part of the <a href="index.html">Qt toolkit</a>.
473Copyright &copy; 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 &copy; 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>
Note: See TracBrowser for help on using the repository browser.