|  | Home · Overviews · Examples |

# QGraphicsTextItem Class Reference
[com.trolltech.qt.gui module]

The `QGraphicsTextItem` class provides a text item that you can add to a `QGraphicsScene` to display formatted text. More...

Inherits `QObject` and `QObject`.

## Detailed Description

The `QGraphicsTextItem` class provides a text item that you can add to a `QGraphicsScene` to display formatted text.

To set the item's text, pass a `QString` to `QGraphicsTextItem`'s constructor, or call `setHtml`/`setPlainText`.

`QGraphicsTextItem` uses the text's formatted size and the associated font to provide a reasonable implementation of `boundingRect`, `shape`, and `contains`. You can set the font by calling `setFont`.

It is possible to make the item editable by setting the Qt::TextEditable flag using `setTextInteractionFlags`.

The item's preferred text width can be set using `setTextWidth` and obtained using `textWidth`.

Note: In order to align HTML text in the center, the item's text width must be set.

See also `QGraphicsSimpleTextItem`, `QGraphicsPathItem`, `QGraphicsRectItem`, `QGraphicsEllipseItem`, `QGraphicsPixmapItem`, `QGraphicsPolygonItem`, `QGraphicsLineItem`, and The Graphics View Framework.