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

QGraphicsTextItem Class Reference
[QtGui module]

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

#include <QGraphicsTextItem>

Inherits QObject and QGraphicsItem.

This class was introduced in Qt 4.2.

Properties

Public Functions

Signals

Additional Inherited Members


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

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


Property Documentation

openExternalLinks : const bool

Specifies whether QGraphicsTextItem should automatically open links using QDesktopServices::openUrl() instead of emitting the anchorClicked signal.

The default value is false.

Access functions:


Member Function Documentation

QGraphicsTextItem::QGraphicsTextItem ( QGraphicsItem * parent = 0, QGraphicsScene * scene = 0 )

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

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

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

QGraphicsTextItem::~QGraphicsTextItem ()

Destroys the QGraphicsTextItem.

void QGraphicsTextItem::adjustSize ()

Adjusts the text item to a reasonable size.

QTextDocument * QGraphicsTextItem::document () const

Returns the item's text document.

See also setDocument().

QFont QGraphicsTextItem::font () const

Returns the item's font, which is used to render the text.

See also setFont().

void QGraphicsTextItem::linkActivated ( const QString & link )   [signal]

This signal is emitted when the user clicks on a link. link is the link that was clicked.

void QGraphicsTextItem::linkHovered ( const QString & link )   [signal]

This signal is emitted when the user hovers over a link. link is the link that was hovered over.

void QGraphicsTextItem::setDocument ( QTextDocument * document )

Sets the text document document on the item.

See also document().

void QGraphicsTextItem::setFont ( const QFont & font )

Sets the font used to render the text item to font.

See also font().

void QGraphicsTextItem::setHtml ( const QString & text )

Sets the item's text to text, assuming that text is HTML formatted.

See also toHtml().

void QGraphicsTextItem::setOpenExternalLinks ( bool open )

See also openExternalLinks().

void QGraphicsTextItem::setPlainText ( const QString & text )

Sets the item's text to text.

See also toHtml().

void QGraphicsTextItem::setTextCursor ( const QTextCursor & cursor )

See also textCursor().

void QGraphicsTextItem::setTextInteractionFlags ( Qt::TextInteractionFlags flags )

Sets the flags flags to specify how the text item should react to user input.

The default for a QGraphicsTextItem is Qt::NoTextInteraction. Setting a value different to Qt::NoTextInteraction will also set the ItemIsFocusable QGraphicsItem flag.

See also textInteractionFlags().

void QGraphicsTextItem::setTextWidth ( qreal width )

Sets the preferred width for the item's text. If the actual text is wider than the specified width then it will be broken into multiple lines.

If width is set to -1 then the text will not be broken into multiple lines unless it is enforced through an explicit line break or a new paragraph.

The default value is -1.

See also textWidth().

QTextCursor QGraphicsTextItem::textCursor () const

See also setTextCursor().

Qt::TextInteractionFlags QGraphicsTextItem::textInteractionFlags () const

Returns the current text interaction flags.

See also setTextInteractionFlags().

qreal QGraphicsTextItem::textWidth () const

Returns the text width.

See also setTextWidth().

QString QGraphicsTextItem::toHtml () const

Returns the item's text converted to HTML, or an empty QString if no text has been set.

See also setHtml().

QString QGraphicsTextItem::toPlainText () const

Returns the item's text converted to plain text, or an empty QString if no text has been set.

See also setPlainText().


Copyright © 2006 Trolltech Trademarks
Qt 4.2.0-snapshot-20060701