Eneboo - Documentación para desarrolladores
|
The QCanvasText class provides a text object on a QCanvas.canvasA canvas text item has text with font, color and alignment attributes. The text and font can be set in the constructor or set or changed later with setText() and setFont(). The color is set with setColor() and the alignment with setTextFlags(). The text item's bounding rectangle is retrieved with boundingRect(). Más...
#include <qcanvas.h>
Métodos públicos | |
QCanvasText (QCanvas *canvas) | |
QCanvasText (const QString &, QCanvas *canvas) | |
QCanvasText (const QString &, QFont, QCanvas *canvas) | |
virtual | ~QCanvasText () |
void | setText (const QString &) |
void | setFont (const QFont &) |
void | setColor (const QColor &) |
QString | text () const |
QFont | font () const |
QColor | color () const |
void | moveBy (double dx, double dy) |
int | textFlags () const |
void | setTextFlags (int) |
QRect | boundingRect () const |
bool | collidesWith (const QCanvasItem *) const |
int | rtti () const |
QCanvasText (QCanvas *canvas) | |
QCanvasText (const QString &, QCanvas *canvas) | |
QCanvasText (const QString &, QFont, QCanvas *canvas) | |
virtual | ~QCanvasText () |
void | setText (const QString &) |
void | setFont (const QFont &) |
void | setColor (const QColor &) |
QString | text () const |
QFont | font () const |
QColor | color () const |
void | moveBy (double dx, double dy) |
int | textFlags () const |
void | setTextFlags (int) |
QRect | boundingRect () const |
bool | collidesWith (const QCanvasItem *) const |
int | rtti () const |
Atributos públicos estáticos | |
static int | RTTI = Rtti_Text |
Métodos protegidos | |
virtual void | draw (QPainter &) |
virtual void | draw (QPainter &) |
The QCanvasText class provides a text object on a QCanvas.
canvas
A canvas text item has text with font, color and alignment attributes. The text and font can be set in the constructor or set or changed later with setText() and setFont(). The color is set with setColor() and the alignment with setTextFlags(). The text item's bounding rectangle is retrieved with boundingRect().
The text can be drawn on a painter with draw().
Like any other canvas item text items can be moved with QCanvasItem::move() and QCanvasItem::moveBy(), or by setting coordinates with QCanvasItem::setX(), QCanvasItem::setY() and QCanvasItem::setZ().
QCanvasText::QCanvasText | ( | QCanvas * | canvas | ) |
Constructs a QCanvasText with the text "\<text\>", on canvas.
Constructs a QCanvasText with the text t, on canvas canvas.
Constructs a QCanvasText with the text t and font f, on the canvas canvas.
QCanvasText::~QCanvasText | ( | ) | [virtual] |
Destroys the canvas text item.
QCanvasText::QCanvasText | ( | QCanvas * | canvas | ) |
virtual QCanvasText::~QCanvasText | ( | ) | [virtual] |
QRect QCanvasText::boundingRect | ( | ) | const [virtual] |
Returns the bounding rectangle of the text.
Implementa QCanvasItem.
QRect QCanvasText::boundingRect | ( | ) | const [virtual] |
Returns the bounding rectangle in pixels that the canvas item covers.
Implementa QCanvasItem.
bool QCanvasText::collidesWith | ( | const QCanvasItem * | i | ) | const [virtual] |
Implementa QCanvasItem.
bool QCanvasText::collidesWith | ( | const QCanvasItem * | other | ) | const [virtual] |
Returns TRUE if the canvas item will collide with the other item after they have moved by their current velocities; otherwise returns FALSE.
Implementa QCanvasItem.
QColor QCanvasText::color | ( | ) | const |
QColor QCanvasText::color | ( | ) | const |
Returns the color of the text.
void QCanvasText::draw | ( | QPainter & | painter | ) | [protected, virtual] |
Draws the text using the painter painter.
Implementa QCanvasItem.
virtual void QCanvasText::draw | ( | QPainter & | painter | ) | [protected, virtual] |
This abstract virtual function draws the canvas item using painter.
Implementa QCanvasItem.
QFont QCanvasText::font | ( | ) | const |
QFont QCanvasText::font | ( | ) | const |
Returns the font in which the text is drawn.
void QCanvasText::moveBy | ( | double | dx, |
double | dy | ||
) | [virtual] |
Moves the canvas item relative to its current position by (dx, dy).
Reimplementado de QCanvasItem.
void QCanvasText::moveBy | ( | double | dx, |
double | dy | ||
) | [virtual] |
Reimplementado de QCanvasItem.
int QCanvasText::rtti | ( | ) | const [virtual] |
Returns 0 (QCanvasItem::Rtti_Item).
Make your derived classes return their own values for rtti(), so that you can distinguish between objects returned by QCanvas::at(). You should use values greater than 1000 to allow for extensions to this class.
Overuse of this functionality can damage it's extensibility. For example, once you have identified a base class of a QCanvasItem found by QCanvas::at(), cast it to that type and call meaningful methods rather than acting upon the object based on its rtti value.
For example:
QCanvasItem* item; // Find an item, e.g. with QCanvasItem::collisions(). ... if (item->rtti() == MySprite::RTTI ) { MySprite* s = (MySprite*)item; if (s->isDamagable()) s->loseHitPoints(1000); if (s->isHot()) myself->loseHitPoints(1000); ... }
Reimplementado de QCanvasItem.
int QCanvasText::rtti | ( | ) | const [virtual] |
void QCanvasText::setColor | ( | const QColor & | ) |
void QCanvasText::setColor | ( | const QColor & | c | ) |
void QCanvasText::setFont | ( | const QFont & | f | ) |
Sets the font in which the text is drawn to font f.
void QCanvasText::setFont | ( | const QFont & | ) |
void QCanvasText::setText | ( | const QString & | ) |
void QCanvasText::setText | ( | const QString & | t | ) |
Sets the text item's text to t. The text may contain newlines.
void QCanvasText::setTextFlags | ( | int | f | ) |
Sets the alignment flags to f. These are a bitwise OR of the flags available to QPainter::drawText() -- see the {Qt::AlignmentFlags}.
void QCanvasText::setTextFlags | ( | int | ) |
QString QCanvasText::text | ( | ) | const |
int QCanvasText::textFlags | ( | ) | const [inline] |
int QCanvasText::textFlags | ( | ) | const [inline] |
Returns the currently set alignment flags.
static int QCanvasText::RTTI = Rtti_Text [static] |
Reimplementado de QCanvasItem.