| Classes - Annotated - Tree - Functions - Home - Structure

# QCanvasText Class Reference
[ canvas module ]

A text object on a QCanvas. More...

`#include <qcanvas.h>`

Inherits QCanvasItem.

List of all member functions.

## Public Members

- 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
- int textFlags () const
- void setTextFlags ( int )
- virtual QRect boundingRect () const
- virtual int rtti () const

## Protected Members

- virtual void draw ( QPainter & )

## Detailed Description

A text object on a QCanvas.

A QCanvasText has text, a font, color, and position.

## Member Function Documentation

### QCanvasText::QCanvasText ( QCanvas * canvas )

Constructs a QCanvasText with the text "", on canvas.

### QCanvasText::QCanvasText ( const QString & t, QCanvas * canvas )

Constructs a QCanvasText with the text t, on canvas.

The text should not contain newlines.

### QCanvasText::QCanvasText ( const QString & t, QFont f, QCanvas * canvas )

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

The text should not contain newlines.

### QCanvasText::~QCanvasText () `[virtual]`

Destruct the sprite.

### QRect QCanvasText::boundingRect () const `[virtual]`

Returns the bounding rectangle of the text.

Reimplemented from QCanvasItem.

### bool QCanvasText::collidesWith ( const QCanvasItem * i ) const `[virtual]`

Reimplemented for internal reasons; the API is not affected.

Reimplemented from QCanvasItem.

### QColor QCanvasText::color () const

Returns the color of the text.

See also setColor().

### void QCanvasText::draw ( QPainter & painter ) `[virtual protected]`

Draws the text.

### QFont QCanvasText::font () const

Returns the font in which the text is drawn.

See also setFont().

### void QCanvasText::moveBy ( double dx, double dy ) `[virtual]`

Reimplemented for internal reasons; the API is not affected.

Reimplemented from QCanvasItem.

### int QCanvasText::rtti () const `[virtual]`

Returns 3.

See also QCanvasItem::rtti().

### void QCanvasText::setColor ( const QColor & c )

Sets the color of the text.

See also color() and setFont().

### void QCanvasText::setFont ( const QFont & f )

Sets the font in which the text is drawn.

See also font().

### void QCanvasText::setText ( const QString & t )

Sets the text to be displayed. The text may contain newlines.

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

### void QCanvasText::setTextFlags ( int f )

Sets the alignment flags. These are a bitwise OR or some of the flags available to QPainter::drawText() - see Qt::AlignmentFlags.

The DontClip and WordBreak flags are not supported.

### QString QCanvasText::text () const

Returns the text to be displayed.

See also setText().

### int QCanvasText::textFlags () const

Returns the currently set alignment flags.

See also setTextFlags() and Qt::AlignmentFlags.

Search the documentation, FAQ, qt-interest archive and more (uses www.trolltech.com):

This file is part of the Qt toolkit, copyright © 1995-2001 Trolltech, all rights reserved.