|  | Home · All Classes · Main Classes · Grouped Classes · Modules · Functions |

# QGraphicsSimpleTextItem Class Reference
[QtGui module]

The QGraphicsSimpleTextItem class provides a text item that you can add to a QGraphicsScene. More...

    #include <QGraphicsSimpleTextItem>

Inherits QGraphicsItem.

This class was introduced in Qt 4.2.

- List of all members, including inherited members

### Public Functions

- QGraphicsSimpleTextItem ( QGraphicsItem * parent = 0, QGraphicsScene * scene = 0 )
- QGraphicsSimpleTextItem ( const QString & text, QGraphicsItem * parent = 0, QGraphicsScene * scene = 0 )
- ~QGraphicsSimpleTextItem ()
- QFont font () const
- QPen pen () const
- void setFont ( const QFont & font )
- void setPen ( const QPen & pen )
- void setText ( const QString & text )
- QString text () const

- 102 public functions inherited from QGraphicsItem

### Additional Inherited Members

- 23 protected functions inherited from QGraphicsItem

## Detailed Description

The QGraphicsSimpleTextItem class provides a text item that you can add to a QGraphicsScene.

To set the item's text, pass a QString to QGraphicsSimpleTextItem's constructor, or call setText().

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().

QGraphicsSimpleText does not display rich text. It is optimized for drawing plain text fast and with low memory overhead.

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

## Member Function Documentation

### QGraphicsSimpleTextItem::QGraphicsSimpleTextItem ( QGraphicsItem * parent = 0, QGraphicsScene * scene = 0 )

Constructs a QGraphicsSimpleTextItem. parent and scene are passed to QGraphicsItem's constructor.

### QGraphicsSimpleTextItem::QGraphicsSimpleTextItem ( const QString & text, QGraphicsItem * parent = 0, QGraphicsScene * scene = 0 )

Constructs a QGraphicsSimpleTextItem, using text as the default plain text. parent and scene are passed to QGraphicsItem's constructor.

### QGraphicsSimpleTextItem::~QGraphicsSimpleTextItem ()

Destroys the QGraphicsSimpleTextItem.

### QFont QGraphicsSimpleTextItem::font () const

Returns the font that is used to draw the item's text.

See also setFont().

### QPen QGraphicsSimpleTextItem::pen () const

Returns the pen that is used to draw the item's text.

See also setPen().

### void QGraphicsSimpleTextItem::setFont ( const QFont & font )

Sets the font that is used to draw the item's text.

See also font().

### void QGraphicsSimpleTextItem::setPen ( const QPen & pen )

Sets the pen that is used to draw the item's text.

See also pen().

### void QGraphicsSimpleTextItem::setText ( const QString & text )

Sets the item's text to text. The text will be displayed as plain text. Newlines characters ('\n') as well as characters of type QChar::LineSeparator will cause item to break the text into multiple lines.

See also text().

### QString QGraphicsSimpleTextItem::text () const

Returns the item's text.

See also setText().