Q3CanvasItem Class Reference |
Constant | Value | Description |
---|---|---|
Q3CanvasItem::Rtti_Item | 0 | Canvas item abstract base class |
Q3CanvasItem::Rtti_Ellipse | 6 | |
Q3CanvasItem::Rtti_Line | 7 | |
Q3CanvasItem::Rtti_Polygon | 4 | |
Q3CanvasItem::Rtti_PolygonalItem | 2 | |
Q3CanvasItem::Rtti_Rectangle | 5 | |
Q3CanvasItem::Rtti_Spline | 8 | |
Q3CanvasItem::Rtti_Sprite | 1 | |
Q3CanvasItem::Rtti_Text | 3 |
Constructs a Q3CanvasItem on canvas canvas.
See also setCanvas().
Destroys the Q3CanvasItem and removes it from its canvas.
The default implementation moves the canvas item, if it is animated(), by the preset velocity if phase is 1, and does nothing if phase is 0.
Note that if you reimplement this function, the reimplementation must not change the canvas in any way, for example it must not add or remove items.
See also Q3Canvas::advance() and setVelocity().
Returns true if the canvas item is in motion; otherwise returns false.
See also setVelocity() and setAnimated().
Returns the bounding rectangle in pixels that the canvas item covers.
See also boundingRectAdvanced().
Returns the bounding rectangle of pixels that the canvas item will cover after advance(1) is called.
See also boundingRect().
Returns the canvas containing the canvas item.
See also setCanvas().
Returns true if the canvas item will collide with the other item after they have moved by their current velocities; otherwise returns false.
See also collisions().
Returns the list of canvas items that this canvas item has collided with.
A collision is generally defined as occurring when the pixels of one item draw on the pixels of another item, but not all subclasses are so precise. Also, since pixel-wise collision detection can be slow, this function works in either exact or inexact mode, according to the exact parameter.
If exact is true, the canvas items returned have been accurately tested for collision with the canvas item.
If exact is false, the canvas items returned are near the canvas item. You can test the canvas items returned using collidesWith() if any are interesting collision candidates. By using this approach, you can ignore some canvas items for which collisions are not relevant.
The returned list is a list of Q3CanvasItems, but often you will need to cast the items to their subclass types. The safe way to do this is to use rtti() before casting. This provides some of the functionality of the standard C++ dynamic cast operation even on compilers where dynamic casts are not available.
Note that a canvas item may be `on' a canvas, e.g. it was created with the canvas as parameter, even though its coordinates place it beyond the edge of the canvas's area. Collision detection only works for canvas items which are wholly or partly within the canvas's area.
Note that if items have a velocity (see setVelocity()), then collision testing is done based on where the item will be when it moves, not its current location. For example, a "ball" item doesn't need to actually embed into a "wall" item before a collision is detected. For items without velocity, plain intersection is used.
This abstract virtual function draws the canvas item using painter.
Shorthand for setVisible(false).
Returns true if the Q3CanvasItem is active; otherwise returns false.
Returns true if the Q3CanvasItem is enabled; otherwise returns false.
Returns true if the canvas item is selected; otherwise returns false.
Returns true if the canvas item is visible; otherwise returns false.
Note that in this context true does not mean that the canvas item is currently in a view, merely that if a view is showing the area where the canvas item is positioned, and the item is not obscured by items with higher z values, and the view is not obscured by overlaying windows, it would be visible.
See also setVisible() and z().
Moves the canvas item to the absolute position (x, y).
Moves the canvas item relative to its current position by (dx, dy).
Returns 0 (Q3CanvasItem::Rtti_Item).
Make your derived classes return their own values for rtti(), so that you can distinguish between objects returned by Q3Canvas::at(). You should use values greater than 1000 to allow for extensions to this class.
Overuse of this functionality can damage its extensibility. For example, once you have identified a base class of a Q3CanvasItem found by Q3Canvas::at(), cast it to that type and call meaningful methods rather than acting upon the object based on its rtti value.
For example:
Q3CanvasItem* item;
// Find an item, e.g. with Q3CanvasItem::collisions().
...
if (item->rtti() == MySprite::RTTI) {
MySprite* s = (MySprite*)item;
if (s->isDamagable()) s->loseHitPoints(1000);
if (s->isHot()) myself->loseHitPoints(1000);
...
}
Sets the active flag of the item to yes. If this changes the item's active state the item will be redrawn when Q3Canvas::update() is next called.
The Q3Canvas, Q3CanvasItem and the Qt-supplied Q3CanvasItem subclasses do not make use of this value. The setActive() function is supplied because many applications need it, but it is up to you how you use the isActive() value.
See also active().
Sets the canvas item to be in motion if y is true, or not if y is false. The speed and direction of the motion is set with setVelocity(), or with setXVelocity() and setYVelocity().
See also animated(), advance(), and Q3Canvas::advance().
Sets the Q3Canvas upon which the canvas item is to be drawn to c.
See also canvas().
Sets the enabled flag of the item to yes. If this changes the item's enabled state the item will be redrawn when Q3Canvas::update() is next called.
The Q3Canvas, Q3CanvasItem and the Qt-supplied Q3CanvasItem subclasses do not make use of this value. The setEnabled() function is supplied because many applications need it, but it is up to you how you use the isEnabled() value.
See also enabled().
Sets the selected flag of the item to yes. If this changes the item's selected state the item will be redrawn when Q3Canvas::update() is next called.
The Q3Canvas, Q3CanvasItem and the Qt-supplied Q3CanvasItem subclasses do not make use of this value. The setSelected() function is supplied because many applications need it, but it is up to you how you use the isSelected() value.
See also selected().
Sets the canvas item to be in motion, moving by vx and vy pixels in the horizontal and vertical directions respectively.
See also advance(), setXVelocity(), and setYVelocity().
Makes the canvas item visible if yes is true, or invisible if yes is false. The change takes effect when Q3Canvas::update() is next called.
See also visible().
Moves the canvas item so that its x-position is x.
Sets the horizontal component of the canvas item's velocity to vx.
See also xVelocity(), setYVelocity(), and setVelocity().
Moves the canvas item so that its y-position is y.
Sets the vertical component of the canvas item's velocity to vy.
See also yVelocity(), setXVelocity(), and setVelocity().
Sets the z index of the canvas item to z. Higher-z items obscure (are in front of) lower-z items.
Shorthand for setVisible(true).
Call this function to repaint the canvas's changed chunks.
Returns the horizontal position of the canvas item. Note that subclasses often have an origin other than the top-left corner.
See also setX().
Returns the horizontal velocity component of the canvas item.
See also setXVelocity().
Returns the vertical position of the canvas item. Note that subclasses often have an origin other than the top-left corner.
See also setY().
Returns the vertical velocity component of the canvas item.
See also setYVelocity().
Returns the z index of the canvas item, which is used for visual order: higher-z items obscure (are in front of) lower-z items.
See also setZ().
Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. | Qt 4.5 | |
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD. | ||
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP ! |
Copyright © 2000-2012 - www.developpez.com