Q3CanvasText Class

The Q3CanvasText class provides a text object on a Q3Canvas. More...

Header: #include <Q3CanvasText>
Inherits: Q3CanvasItem

Public Functions

Q3CanvasText(Q3Canvas * canvas)
Q3CanvasText(const QString & t, Q3Canvas * canvas)
Q3CanvasText(const QString & t, QFont f, Q3Canvas * canvas)
virtual ~Q3CanvasText()
QColor color() const
QFont font() const
void setColor(const QColor & c)
void setFont(const QFont & f)
void setText(const QString & t)
void setTextFlags(int f)
QString text() const
int textFlags() const

Reimplemented Public Functions

virtual QRect boundingRect() const
virtual bool collidesWith(const Q3CanvasItem * i) const
virtual void moveBy(double dx, double dy)
virtual int rtti() const

Reimplemented Protected Functions

virtual void draw(QPainter & painter)

Detailed Description

The Q3CanvasText class provides a text object on a Q3Canvas.

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 Q3CanvasItem::move() and Q3CanvasItem::moveBy(), or by setting coordinates with Q3CanvasItem::setX(), Q3CanvasItem::setY() and Q3CanvasItem::setZ().

See also QtCanvas and Porting to Graphics View.

Member Function Documentation

Q3CanvasText::Q3CanvasText(Q3Canvas * canvas)

Constructs a Q3CanvasText with the text "<text>", on canvas.

Q3CanvasText::Q3CanvasText(const QString & t, Q3Canvas * canvas)

Constructs a Q3CanvasText with the text t, on canvas canvas.

Q3CanvasText::Q3CanvasText(const QString & t, QFont f, Q3Canvas * canvas)

Constructs a Q3CanvasText with the text t and font f, on the canvas canvas.

[virtual] Q3CanvasText::~Q3CanvasText()

Destroys the canvas text item.

[virtual] QRect Q3CanvasText::boundingRect() const

Reimplemented from Q3CanvasItem::boundingRect().

Returns the bounding rectangle of the text.

[virtual] bool Q3CanvasText::collidesWith(const Q3CanvasItem * i) const

Reimplemented from Q3CanvasItem::collidesWith().

QColor Q3CanvasText::color() const

Returns the color of the text.

See also setColor().

[virtual protected] void Q3CanvasText::draw(QPainter & painter)

Reimplemented from Q3CanvasItem::draw().

Draws the text using the painter painter.

QFont Q3CanvasText::font() const

Returns the font in which the text is drawn.

See also setFont().

[virtual] void Q3CanvasText::moveBy(double dx, double dy)

Reimplemented from Q3CanvasItem::moveBy().

[virtual] int Q3CanvasText::rtti() const

Reimplemented from Q3CanvasItem::rtti().

Returns 3 (Q3CanvasItem::Rtti_Text).

See also Q3CanvasItem::rtti().

void Q3CanvasText::setColor(const QColor & c)

Sets the color of the text to the color c.

See also color() and setFont().

void Q3CanvasText::setFont(const QFont & f)

Sets the font in which the text is drawn to font f.

See also font().

void Q3CanvasText::setText(const QString & t)

Sets the text item's text to t. The text may contain newlines.

See also text(), setFont(), setColor(), and setTextFlags().

void Q3CanvasText::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.

See also textFlags(), setFont(), and setColor().

QString Q3CanvasText::text() const

Returns the text item's text.

See also setText().

int Q3CanvasText::textFlags() const

Returns the currently set alignment flags.

See also setTextFlags() and Qt::AlignmentFlag.

© 2016 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.