<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en_US" lang="en_US"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <!-- qgraphicsitem.cpp --> <title>Qt 4.8: QGraphicsTextItem Class Reference</title> <link rel="stylesheet" type="text/css" href="style/style.css" /> <script src="scripts/jquery.js" type="text/javascript"></script> <script src="scripts/functions.js" type="text/javascript"></script> <link rel="stylesheet" type="text/css" href="style/superfish.css" /> <link rel="stylesheet" type="text/css" href="style/narrow.css" /> <!--[if IE]> <meta name="MSSmartTagsPreventParsing" content="true"> <meta http-equiv="imagetoolbar" content="no"> <![endif]--> <!--[if lt IE 7]> <link rel="stylesheet" type="text/css" href="style/style_ie6.css"> <![endif]--> <!--[if IE 7]> <link rel="stylesheet" type="text/css" href="style/style_ie7.css"> <![endif]--> <!--[if IE 8]> <link rel="stylesheet" type="text/css" href="style/style_ie8.css"> <![endif]--> <script src="scripts/superfish.js" type="text/javascript"></script> <script src="scripts/narrow.js" type="text/javascript"></script> </head> <body class="" onload="CheckEmptyAndLoadList();"> <div class="header" id="qtdocheader"> <div class="content"> <div id="nav-logo"> <a href="index.html">Home</a></div> <a href="index.html" class="qtref"><span>Qt Reference Documentation</span></a> <div id="narrowsearch"></div> <div id="nav-topright"> <ul> <li class="nav-topright-home"><a href="http://qt.digia.com/">Qt HOME</a></li> <li class="nav-topright-dev"><a href="http://qt-project.org/">DEV</a></li> <li class="nav-topright-doc nav-topright-doc-active"><a href="http://qt-project.org/doc/"> DOC</a></li> <li class="nav-topright-blog"><a href="http://blog.qt.digia.com/">BLOG</a></li> </ul> </div> <div id="shortCut"> <ul> <li class="shortCut-topleft-inactive"><span><a href="index.html">Qt 4.8</a></span></li> <li class="shortCut-topleft-active"><a href="http://qt-project.org/doc/">ALL VERSIONS </a></li> </ul> </div> <ul class="sf-menu" id="narrowmenu"> <li><a href="#">API Lookup</a> <ul> <li><a href="classes.html">Class index</a></li> <li><a href="functions.html">Function index</a></li> <li><a href="modules.html">Modules</a></li> <li><a href="namespaces.html">Namespaces</a></li> <li><a href="qtglobal.html">Global Declarations</a></li> <li><a href="qdeclarativeelements.html">QML elements</a></li> </ul> </li> <li><a href="#">Qt Topics</a> <ul> <li><a href="qt-basic-concepts.html">Programming with Qt</a></li> <li><a href="qtquick.html">Device UIs & Qt Quick</a></li> <li><a href="qt-gui-concepts.html">UI Design with Qt</a></li> <li><a href="supported-platforms.html">Supported Platforms</a></li> <li><a href="technology-apis.html">Qt and Key Technologies</a></li> <li><a href="best-practices.html">How-To's and Best Practices</a></li> </ul> </li> <li><a href="#">Examples</a> <ul> <li><a href="all-examples.html">Examples</a></li> <li><a href="tutorials.html">Tutorials</a></li> <li><a href="demos.html">Demos</a></li> <li><a href="qdeclarativeexamples.html">QML Examples</a></li> </ul> </li> </ul> </div> </div> <div class="wrapper"> <div class="hd"> <span></span> </div> <div class="bd group"> <div class="sidebar"> <div class="searchlabel"> Search index:</div> <div class="search" id="sidebarsearch"> <form id="qtdocsearch" action="" onsubmit="return false;"> <fieldset> <input type="text" name="searchstring" id="pageType" value="" /> <div id="resultdialog"> <a href="#" id="resultclose">Close</a> <p id="resultlinks" class="all"><a href="#" id="showallresults">All</a> | <a href="#" id="showapiresults">API</a> | <a href="#" id="showarticleresults">Articles</a> | <a href="#" id="showexampleresults">Examples</a></p> <p id="searchcount" class="all"><span id="resultcount"></span><span id="apicount"></span><span id="articlecount"></span><span id="examplecount"></span> results:</p> <ul id="resultlist" class="all"> </ul> </div> </fieldset> </form> </div> <div class="box first bottombar" id="lookup"> <h2 title="API Lookup"><span></span> API Lookup</h2> <div id="list001" class="list"> <ul id="ul001" > <li class="defaultLink"><a href="classes.html">Class index</a></li> <li class="defaultLink"><a href="functions.html">Function index</a></li> <li class="defaultLink"><a href="modules.html">Modules</a></li> <li class="defaultLink"><a href="namespaces.html">Namespaces</a></li> <li class="defaultLink"><a href="qtglobal.html">Global Declarations</a></li> <li class="defaultLink"><a href="qdeclarativeelements.html">QML elements</a></li> </ul> </div> </div> <div class="box bottombar" id="topics"> <h2 title="Qt Topics"><span></span> Qt Topics</h2> <div id="list002" class="list"> <ul id="ul002" > <li class="defaultLink"><a href="qt-basic-concepts.html">Programming with Qt</a></li> <li class="defaultLink"><a href="qtquick.html">Device UIs & Qt Quick</a></li> <li class="defaultLink"><a href="qt-gui-concepts.html">UI Design with Qt</a></li> <li class="defaultLink"><a href="supported-platforms.html">Supported Platforms</a></li> <li class="defaultLink"><a href="technology-apis.html">Qt and Key Technologies</a></li> <li class="defaultLink"><a href="best-practices.html">How-To's and Best Practices</a></li> </ul> </div> </div> <div class="box" id="examples"> <h2 title="Examples"><span></span> Examples</h2> <div id="list003" class="list"> <ul id="ul003"> <li class="defaultLink"><a href="all-examples.html">Examples</a></li> <li class="defaultLink"><a href="tutorials.html">Tutorials</a></li> <li class="defaultLink"><a href="demos.html">Demos</a></li> <li class="defaultLink"><a href="qdeclarativeexamples.html">QML Examples</a></li> </ul> </div> </div> </div> <div class="wrap"> <div class="toolbar"> <div class="breadcrumb toolblock"> <ul> <li class="first"><a href="index.html">Home</a></li> <!-- Breadcrumbs go here --> <li><a href="modules.html">Modules</a></li> <li><a href="qtgui.html">QtGui</a></li> <li>QGraphicsTextItem</li> </ul> </div> <div class="toolbuttons toolblock"> <ul> <li id="smallA" class="t_button">A</li> <li id="medA" class="t_button active">A</li> <li id="bigA" class="t_button">A</li> <li id="print" class="t_button"><a href="javascript:this.print();"> <span>Print</span></a></li> </ul> </div> </div> <div class="content mainContent"> <div class="toc"> <h3><a name="toc">Contents</a></h3> <ul> <li class="level1"><a href="#properties">Properties</a></li> <li class="level1"><a href="#public-functions">Public Functions</a></li> <li class="level1"><a href="#signals">Signals</a></li> <li class="level1"><a href="#protected-functions">Protected Functions</a></li> <li class="level1"><a href="#details">Detailed Description</a></li> </ul> </div> <h1 class="title">QGraphicsTextItem Class Reference</h1> <!-- $$$QGraphicsTextItem-brief --> <p>The QGraphicsTextItem class provides a text item that you can add to a <a href="qgraphicsscene.html">QGraphicsScene</a> to display formatted text. <a href="#details">More...</a></p> <!-- @@@QGraphicsTextItem --> <pre class="cpp"> <span class="preprocessor">#include <QGraphicsTextItem></span></pre><p><b>Inherits: </b><a href="qgraphicsobject.html">QGraphicsObject</a>.</p> <p>This class was introduced in Qt 4.2.</p> <ul> <li><a href="qgraphicstextitem-members.html">List of all members, including inherited members</a></li> </ul> <a name="properties"></a> <h2>Properties</h2> <ul> <li class="fn"><b><a href="qgraphicstextitem.html#openExternalLinks-prop">openExternalLinks</a></b> : bool</li> <li class="fn"><b><a href="qgraphicstextitem.html#textCursor-prop">textCursor</a></b> : QTextCursor</li> </ul> <ul> <li class="fn">12 properties inherited from <a href="qgraphicsobject.html#properties">QGraphicsObject</a></li> <li class="fn">1 property inherited from <a href="qobject.html#properties">QObject</a></li> </ul> <a name="public-functions"></a> <h2>Public Functions</h2> <table class="alignedsummary"> <tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qgraphicstextitem.html#QGraphicsTextItem">QGraphicsTextItem</a></b> ( QGraphicsItem * <i>parent</i> = 0 )</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qgraphicstextitem.html#QGraphicsTextItem-2">QGraphicsTextItem</a></b> ( const QString & <i>text</i>, QGraphicsItem * <i>parent</i> = 0 )</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qgraphicstextitem.html#dtor.QGraphicsTextItem">~QGraphicsTextItem</a></b> ()</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qgraphicstextitem.html#adjustSize">adjustSize</a></b> ()</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QColor </td><td class="memItemRight bottomAlign"><b><a href="qgraphicstextitem.html#defaultTextColor">defaultTextColor</a></b> () const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QTextDocument * </td><td class="memItemRight bottomAlign"><b><a href="qgraphicstextitem.html#document">document</a></b> () const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QFont </td><td class="memItemRight bottomAlign"><b><a href="qgraphicstextitem.html#font">font</a></b> () const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qgraphicstextitem.html#openExternalLinks-prop">openExternalLinks</a></b> () const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qgraphicstextitem.html#setDefaultTextColor">setDefaultTextColor</a></b> ( const QColor & <i>col</i> )</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qgraphicstextitem.html#setDocument">setDocument</a></b> ( QTextDocument * <i>document</i> )</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qgraphicstextitem.html#setFont">setFont</a></b> ( const QFont & <i>font</i> )</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qgraphicstextitem.html#setHtml">setHtml</a></b> ( const QString & <i>text</i> )</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qgraphicstextitem.html#openExternalLinks-prop">setOpenExternalLinks</a></b> ( bool <i>open</i> )</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qgraphicstextitem.html#setPlainText">setPlainText</a></b> ( const QString & <i>text</i> )</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qgraphicstextitem.html#setTabChangesFocus">setTabChangesFocus</a></b> ( bool <i>b</i> )</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qgraphicstextitem.html#textCursor-prop">setTextCursor</a></b> ( const QTextCursor & <i>cursor</i> )</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qgraphicstextitem.html#setTextInteractionFlags">setTextInteractionFlags</a></b> ( Qt::TextInteractionFlags <i>flags</i> )</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qgraphicstextitem.html#setTextWidth">setTextWidth</a></b> ( qreal <i>width</i> )</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qgraphicstextitem.html#tabChangesFocus">tabChangesFocus</a></b> () const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QTextCursor </td><td class="memItemRight bottomAlign"><b><a href="qgraphicstextitem.html#textCursor-prop">textCursor</a></b> () const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> Qt::TextInteractionFlags </td><td class="memItemRight bottomAlign"><b><a href="qgraphicstextitem.html#textInteractionFlags">textInteractionFlags</a></b> () const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> qreal </td><td class="memItemRight bottomAlign"><b><a href="qgraphicstextitem.html#textWidth">textWidth</a></b> () const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qgraphicstextitem.html#toHtml">toHtml</a></b> () const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qgraphicstextitem.html#toPlainText">toPlainText</a></b> () const</td></tr> </table> <a name="reimplemented-public-functions"></a> <h2>Reimplemented Public Functions</h2> <table class="alignedsummary"> <tr><td class="memItemLeft rightAlign topAlign"> virtual QRectF </td><td class="memItemRight bottomAlign"><b><a href="qgraphicstextitem.html#boundingRect">boundingRect</a></b> () const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> virtual bool </td><td class="memItemRight bottomAlign"><b><a href="qgraphicstextitem.html#contains">contains</a></b> ( const QPointF & <i>point</i> ) const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> virtual bool </td><td class="memItemRight bottomAlign"><b><a href="qgraphicstextitem.html#isObscuredBy">isObscuredBy</a></b> ( const QGraphicsItem * <i>item</i> ) const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> virtual QPainterPath </td><td class="memItemRight bottomAlign"><b><a href="qgraphicstextitem.html#opaqueArea">opaqueArea</a></b> () const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="qgraphicstextitem.html#paint">paint</a></b> ( QPainter * <i>painter</i>, const QStyleOptionGraphicsItem * <i>option</i>, QWidget * <i>widget</i> )</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> virtual QPainterPath </td><td class="memItemRight bottomAlign"><b><a href="qgraphicstextitem.html#shape">shape</a></b> () const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> virtual int </td><td class="memItemRight bottomAlign"><b><a href="qgraphicstextitem.html#type">type</a></b> () const</td></tr> </table> <ul> <li class="fn">2 public functions inherited from <a href="qgraphicsobject.html#public-functions">QGraphicsObject</a></li> <li class="fn">29 public functions inherited from <a href="qobject.html#public-functions">QObject</a></li> <li class="fn">177 public functions inherited from <a href="qgraphicsitem.html#public-functions">QGraphicsItem</a></li> </ul> <a name="signals"></a> <h2>Signals</h2> <table class="alignedsummary"> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qgraphicstextitem.html#linkActivated">linkActivated</a></b> ( const QString & <i>link</i> )</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qgraphicstextitem.html#linkHovered">linkHovered</a></b> ( const QString & <i>link</i> )</td></tr> </table> <ul> <li class="fn">9 signals inherited from <a href="qgraphicsobject.html#signals">QGraphicsObject</a></li> <li class="fn">1 signal inherited from <a href="qobject.html#signals">QObject</a></li> </ul> <a name="reimplemented-protected-functions"></a> <h2>Reimplemented Protected Functions</h2> <table class="alignedsummary"> <tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="qgraphicstextitem.html#contextMenuEvent">contextMenuEvent</a></b> ( QGraphicsSceneContextMenuEvent * <i>event</i> )</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="qgraphicstextitem.html#dragEnterEvent">dragEnterEvent</a></b> ( QGraphicsSceneDragDropEvent * <i>event</i> )</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="qgraphicstextitem.html#dragLeaveEvent">dragLeaveEvent</a></b> ( QGraphicsSceneDragDropEvent * <i>event</i> )</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="qgraphicstextitem.html#dragMoveEvent">dragMoveEvent</a></b> ( QGraphicsSceneDragDropEvent * <i>event</i> )</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="qgraphicstextitem.html#dropEvent">dropEvent</a></b> ( QGraphicsSceneDragDropEvent * <i>event</i> )</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="qgraphicstextitem.html#focusInEvent">focusInEvent</a></b> ( QFocusEvent * <i>event</i> )</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="qgraphicstextitem.html#focusOutEvent">focusOutEvent</a></b> ( QFocusEvent * <i>event</i> )</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="qgraphicstextitem.html#hoverEnterEvent">hoverEnterEvent</a></b> ( QGraphicsSceneHoverEvent * <i>event</i> )</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="qgraphicstextitem.html#hoverLeaveEvent">hoverLeaveEvent</a></b> ( QGraphicsSceneHoverEvent * <i>event</i> )</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="qgraphicstextitem.html#hoverMoveEvent">hoverMoveEvent</a></b> ( QGraphicsSceneHoverEvent * <i>event</i> )</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="qgraphicstextitem.html#inputMethodEvent">inputMethodEvent</a></b> ( QInputMethodEvent * <i>event</i> )</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> virtual QVariant </td><td class="memItemRight bottomAlign"><b><a href="qgraphicstextitem.html#inputMethodQuery">inputMethodQuery</a></b> ( Qt::InputMethodQuery <i>query</i> ) const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="qgraphicstextitem.html#keyPressEvent">keyPressEvent</a></b> ( QKeyEvent * <i>event</i> )</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="qgraphicstextitem.html#keyReleaseEvent">keyReleaseEvent</a></b> ( QKeyEvent * <i>event</i> )</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="qgraphicstextitem.html#mouseDoubleClickEvent">mouseDoubleClickEvent</a></b> ( QGraphicsSceneMouseEvent * <i>event</i> )</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="qgraphicstextitem.html#mouseMoveEvent">mouseMoveEvent</a></b> ( QGraphicsSceneMouseEvent * <i>event</i> )</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="qgraphicstextitem.html#mousePressEvent">mousePressEvent</a></b> ( QGraphicsSceneMouseEvent * <i>event</i> )</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="qgraphicstextitem.html#mouseReleaseEvent">mouseReleaseEvent</a></b> ( QGraphicsSceneMouseEvent * <i>event</i> )</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> virtual bool </td><td class="memItemRight bottomAlign"><b><a href="qgraphicstextitem.html#sceneEvent">sceneEvent</a></b> ( QEvent * <i>event</i> )</td></tr> </table> <ul> <li class="fn">8 protected functions inherited from <a href="qobject.html#protected-functions">QObject</a></li> <li class="fn">24 protected functions inherited from <a href="qgraphicsitem.html#protected-functions">QGraphicsItem</a></li> </ul> <h3>Additional Inherited Members</h3> <ul> <li class="fn">1 public slot inherited from <a href="qobject.html#public-slots">QObject</a></li> <li class="fn">7 static public members inherited from <a href="qobject.html#static-public-members">QObject</a></li> <li class="fn">2 static public members inherited from <a href="qgraphicsitem.html#static-public-members">QGraphicsItem</a></li> <li class="fn">8 protected functions inherited from <a href="qobject.html#protected-functions">QObject</a></li> <li class="fn">24 protected functions inherited from <a href="qgraphicsitem.html#protected-functions">QGraphicsItem</a></li> <li class="fn">1 protected slot inherited from <a href="qgraphicsobject.html#protected-slots">QGraphicsObject</a></li> </ul> <a name="details"></a> <!-- $$$QGraphicsTextItem-description --> <div class="descr"> <h2>Detailed Description</h2> <p>The QGraphicsTextItem class provides a text item that you can add to a <a href="qgraphicsscene.html">QGraphicsScene</a> to display formatted text.</p> <p>If you only need to show plain text in an item, consider using <a href="qgraphicssimpletextitem.html">QGraphicsSimpleTextItem</a> instead.</p> <p>To set the item's text, pass a <a href="qstring.html">QString</a> to QGraphicsTextItem's constructor, or call <a href="qgraphicstextitem.html#setHtml">setHtml</a>()/<a href="qgraphicstextitem.html#setPlainText">setPlainText</a>().</p> <p>QGraphicsTextItem uses the text's formatted size and the associated font to provide a reasonable implementation of <a href="qgraphicstextitem.html#boundingRect">boundingRect</a>(), <a href="qgraphicstextitem.html#shape">shape</a>(), and <a href="qgraphicstextitem.html#contains">contains</a>(). You can set the font by calling <a href="qgraphicstextitem.html#setFont">setFont</a>().</p> <p>It is possible to make the item editable by setting the <a href="qt.html#TextInteractionFlag-enum">Qt::TextEditorInteraction</a> flag using <a href="qgraphicstextitem.html#setTextInteractionFlags">setTextInteractionFlags</a>().</p> <p>The item's preferred text width can be set using <a href="qgraphicstextitem.html#setTextWidth">setTextWidth</a>() and obtained using <a href="qgraphicstextitem.html#textWidth">textWidth</a>().</p> <p><b>Note:</b> In order to align HTML text in the center, the item's text width must be set.</p> <p class="centerAlign"><img src="images/graphicsview-textitem.png" alt="" /></p><p><b>Note:</b> QGraphicsTextItem accepts <a href="qgraphicsitem.html#acceptHoverEvents">hover events</a> by default. You can change this with <a href="qgraphicsitem.html#setAcceptHoverEvents">setAcceptHoverEvents()</a>.</p> </div> <p><b>See also </b><a href="qgraphicssimpletextitem.html">QGraphicsSimpleTextItem</a>, <a href="qgraphicspathitem.html">QGraphicsPathItem</a>, <a href="qgraphicsrectitem.html">QGraphicsRectItem</a>, <a href="qgraphicsellipseitem.html">QGraphicsEllipseItem</a>, <a href="qgraphicspixmapitem.html">QGraphicsPixmapItem</a>, <a href="qgraphicspolygonitem.html">QGraphicsPolygonItem</a>, <a href="qgraphicslineitem.html">QGraphicsLineItem</a>, and <a href="graphicsview.html">Graphics View Framework</a>.</p> <!-- @@@QGraphicsTextItem --> <div class="prop"> <h2>Property Documentation</h2> <!-- $$$openExternalLinks-prop$$$openExternalLinks$$$setOpenExternalLinksbool --> <h3 class="fn"><a name="openExternalLinks-prop"></a><span class="name">openExternalLinks</span> : <span class="type">bool</span></h3> <p>Specifies whether <a href="qgraphicstextitem.html">QGraphicsTextItem</a> should automatically open links using <a href="qdesktopservices.html#openUrl">QDesktopServices::openUrl</a>() instead of emitting the linkActivated signal.</p> <p>The default value is false.</p> <p><b>Access functions:</b></p> <table class="alignedsummary"> <tr><td class="memItemLeft topAlign rightAlign"> bool </td><td class="memItemRight bottomAlign"><span class="name"><b>openExternalLinks</b></span> () const</td></tr> <tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b>setOpenExternalLinks</b></span> ( bool <i>open</i> )</td></tr> </table> <!-- @@@openExternalLinks --> <!-- $$$textCursor-prop$$$textCursor$$$setTextCursorconstQTextCursor& --> <h3 class="fn"><a name="textCursor-prop"></a><span class="name">textCursor</span> : <span class="type"><a href="qtextcursor.html">QTextCursor</a></span></h3> <p>This property represents the visible text cursor in an editable text item.</p> <p>By default, if the item's text has not been set, this property contains a null text cursor; otherwise it contains a text cursor placed at the start of the item's document.</p> <p><b>Access functions:</b></p> <table class="alignedsummary"> <tr><td class="memItemLeft topAlign rightAlign"> QTextCursor </td><td class="memItemRight bottomAlign"><span class="name"><b>textCursor</b></span> () const</td></tr> <tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b>setTextCursor</b></span> ( const QTextCursor & <i>cursor</i> )</td></tr> </table> <!-- @@@textCursor --> </div> <div class="func"> <h2>Member Function Documentation</h2> <!-- $$$QGraphicsTextItem[overload1]$$$QGraphicsTextItemQGraphicsItem* --> <h3 class="fn"><a name="QGraphicsTextItem"></a>QGraphicsTextItem::<span class="name">QGraphicsTextItem</span> ( <span class="type"><a href="qgraphicsitem.html">QGraphicsItem</a></span> * <i>parent</i> = 0 )</h3> <p>Constructs a <a href="qgraphicstextitem.html">QGraphicsTextItem</a>. <i>parent</i> is passed to <a href="qgraphicsitem.html">QGraphicsItem</a>'s constructor.</p> <p><b>See also </b><a href="qgraphicsscene.html#addItem">QGraphicsScene::addItem</a>().</p> <!-- @@@QGraphicsTextItem --> <!-- $$$QGraphicsTextItem$$$QGraphicsTextItemconstQString&QGraphicsItem* --> <h3 class="fn"><a name="QGraphicsTextItem-2"></a>QGraphicsTextItem::<span class="name">QGraphicsTextItem</span> ( const <span class="type"><a href="qstring.html">QString</a></span> & <i>text</i>, <span class="type"><a href="qgraphicsitem.html">QGraphicsItem</a></span> * <i>parent</i> = 0 )</h3> <p>Constructs a <a href="qgraphicstextitem.html">QGraphicsTextItem</a>, using <i>text</i> as the default plain text. <i>parent</i> is passed to <a href="qgraphicsitem.html">QGraphicsItem</a>'s constructor.</p> <p><b>See also </b><a href="qgraphicsscene.html#addItem">QGraphicsScene::addItem</a>().</p> <!-- @@@QGraphicsTextItem --> <!-- $$$~QGraphicsTextItem[overload1]$$$~QGraphicsTextItem --> <h3 class="fn"><a name="dtor.QGraphicsTextItem"></a>QGraphicsTextItem::<span class="name">~QGraphicsTextItem</span> ()</h3> <p>Destroys the <a href="qgraphicstextitem.html">QGraphicsTextItem</a>.</p> <!-- @@@~QGraphicsTextItem --> <!-- $$$adjustSize[overload1]$$$adjustSize --> <h3 class="fn"><a name="adjustSize"></a><span class="type">void</span> QGraphicsTextItem::<span class="name">adjustSize</span> ()</h3> <p>Adjusts the text item to a reasonable size.</p> <!-- @@@adjustSize --> <!-- $$$boundingRect[overload1]$$$boundingRect --> <h3 class="fn"><a name="boundingRect"></a><span class="type"><a href="qrectf.html">QRectF</a></span> QGraphicsTextItem::<span class="name">boundingRect</span> () const<tt> [virtual]</tt></h3> <p>Reimplemented from <a href="qgraphicsitem.html#boundingRect">QGraphicsItem::boundingRect</a>().</p> <!-- @@@boundingRect --> <!-- $$$contains[overload1]$$$containsconstQPointF& --> <h3 class="fn"><a name="contains"></a><span class="type">bool</span> QGraphicsTextItem::<span class="name">contains</span> ( const <span class="type"><a href="qpointf.html">QPointF</a></span> & <i>point</i> ) const<tt> [virtual]</tt></h3> <p>Reimplemented from <a href="qgraphicsitem.html#contains">QGraphicsItem::contains</a>().</p> <!-- @@@contains --> <!-- $$$contextMenuEvent[overload1]$$$contextMenuEventQGraphicsSceneContextMenuEvent* --> <h3 class="fn"><a name="contextMenuEvent"></a><span class="type">void</span> QGraphicsTextItem::<span class="name">contextMenuEvent</span> ( <span class="type"><a href="qgraphicsscenecontextmenuevent.html">QGraphicsSceneContextMenuEvent</a></span> * <i>event</i> )<tt> [virtual protected]</tt></h3> <p>Reimplemented from <a href="qgraphicsitem.html#contextMenuEvent">QGraphicsItem::contextMenuEvent</a>().</p> <!-- @@@contextMenuEvent --> <!-- $$$defaultTextColor[overload1]$$$defaultTextColor --> <h3 class="fn"><a name="defaultTextColor"></a><span class="type"><a href="qcolor.html">QColor</a></span> QGraphicsTextItem::<span class="name">defaultTextColor</span> () const</h3> <p>Returns the default text color that is used to for unformatted text.</p> <p><b>See also </b><a href="qgraphicstextitem.html#setDefaultTextColor">setDefaultTextColor</a>().</p> <!-- @@@defaultTextColor --> <!-- $$$document[overload1]$$$document --> <h3 class="fn"><a name="document"></a><span class="type"><a href="qtextdocument.html">QTextDocument</a></span> * QGraphicsTextItem::<span class="name">document</span> () const</h3> <p>Returns the item's text document.</p> <p><b>See also </b><a href="qgraphicstextitem.html#setDocument">setDocument</a>().</p> <!-- @@@document --> <!-- $$$dragEnterEvent[overload1]$$$dragEnterEventQGraphicsSceneDragDropEvent* --> <h3 class="fn"><a name="dragEnterEvent"></a><span class="type">void</span> QGraphicsTextItem::<span class="name">dragEnterEvent</span> ( <span class="type"><a href="qgraphicsscenedragdropevent.html">QGraphicsSceneDragDropEvent</a></span> * <i>event</i> )<tt> [virtual protected]</tt></h3> <p>Reimplemented from <a href="qgraphicsitem.html#dragEnterEvent">QGraphicsItem::dragEnterEvent</a>().</p> <!-- @@@dragEnterEvent --> <!-- $$$dragLeaveEvent[overload1]$$$dragLeaveEventQGraphicsSceneDragDropEvent* --> <h3 class="fn"><a name="dragLeaveEvent"></a><span class="type">void</span> QGraphicsTextItem::<span class="name">dragLeaveEvent</span> ( <span class="type"><a href="qgraphicsscenedragdropevent.html">QGraphicsSceneDragDropEvent</a></span> * <i>event</i> )<tt> [virtual protected]</tt></h3> <p>Reimplemented from <a href="qgraphicsitem.html#dragLeaveEvent">QGraphicsItem::dragLeaveEvent</a>().</p> <!-- @@@dragLeaveEvent --> <!-- $$$dragMoveEvent[overload1]$$$dragMoveEventQGraphicsSceneDragDropEvent* --> <h3 class="fn"><a name="dragMoveEvent"></a><span class="type">void</span> QGraphicsTextItem::<span class="name">dragMoveEvent</span> ( <span class="type"><a href="qgraphicsscenedragdropevent.html">QGraphicsSceneDragDropEvent</a></span> * <i>event</i> )<tt> [virtual protected]</tt></h3> <p>Reimplemented from <a href="qgraphicsitem.html#dragMoveEvent">QGraphicsItem::dragMoveEvent</a>().</p> <!-- @@@dragMoveEvent --> <!-- $$$dropEvent[overload1]$$$dropEventQGraphicsSceneDragDropEvent* --> <h3 class="fn"><a name="dropEvent"></a><span class="type">void</span> QGraphicsTextItem::<span class="name">dropEvent</span> ( <span class="type"><a href="qgraphicsscenedragdropevent.html">QGraphicsSceneDragDropEvent</a></span> * <i>event</i> )<tt> [virtual protected]</tt></h3> <p>Reimplemented from <a href="qgraphicsitem.html#dropEvent">QGraphicsItem::dropEvent</a>().</p> <!-- @@@dropEvent --> <!-- $$$focusInEvent[overload1]$$$focusInEventQFocusEvent* --> <h3 class="fn"><a name="focusInEvent"></a><span class="type">void</span> QGraphicsTextItem::<span class="name">focusInEvent</span> ( <span class="type"><a href="qfocusevent.html">QFocusEvent</a></span> * <i>event</i> )<tt> [virtual protected]</tt></h3> <p>Reimplemented from <a href="qgraphicsitem.html#focusInEvent">QGraphicsItem::focusInEvent</a>().</p> <!-- @@@focusInEvent --> <!-- $$$focusOutEvent[overload1]$$$focusOutEventQFocusEvent* --> <h3 class="fn"><a name="focusOutEvent"></a><span class="type">void</span> QGraphicsTextItem::<span class="name">focusOutEvent</span> ( <span class="type"><a href="qfocusevent.html">QFocusEvent</a></span> * <i>event</i> )<tt> [virtual protected]</tt></h3> <p>Reimplemented from <a href="qgraphicsitem.html#focusOutEvent">QGraphicsItem::focusOutEvent</a>().</p> <!-- @@@focusOutEvent --> <!-- $$$font[overload1]$$$font --> <h3 class="fn"><a name="font"></a><span class="type"><a href="qfont.html">QFont</a></span> QGraphicsTextItem::<span class="name">font</span> () const</h3> <p>Returns the item's font, which is used to render the text.</p> <p><b>See also </b><a href="qgraphicstextitem.html#setFont">setFont</a>().</p> <!-- @@@font --> <!-- $$$hoverEnterEvent[overload1]$$$hoverEnterEventQGraphicsSceneHoverEvent* --> <h3 class="fn"><a name="hoverEnterEvent"></a><span class="type">void</span> QGraphicsTextItem::<span class="name">hoverEnterEvent</span> ( <span class="type"><a href="qgraphicsscenehoverevent.html">QGraphicsSceneHoverEvent</a></span> * <i>event</i> )<tt> [virtual protected]</tt></h3> <p>Reimplemented from <a href="qgraphicsitem.html#hoverEnterEvent">QGraphicsItem::hoverEnterEvent</a>().</p> <!-- @@@hoverEnterEvent --> <!-- $$$hoverLeaveEvent[overload1]$$$hoverLeaveEventQGraphicsSceneHoverEvent* --> <h3 class="fn"><a name="hoverLeaveEvent"></a><span class="type">void</span> QGraphicsTextItem::<span class="name">hoverLeaveEvent</span> ( <span class="type"><a href="qgraphicsscenehoverevent.html">QGraphicsSceneHoverEvent</a></span> * <i>event</i> )<tt> [virtual protected]</tt></h3> <p>Reimplemented from <a href="qgraphicsitem.html#hoverLeaveEvent">QGraphicsItem::hoverLeaveEvent</a>().</p> <!-- @@@hoverLeaveEvent --> <!-- $$$hoverMoveEvent[overload1]$$$hoverMoveEventQGraphicsSceneHoverEvent* --> <h3 class="fn"><a name="hoverMoveEvent"></a><span class="type">void</span> QGraphicsTextItem::<span class="name">hoverMoveEvent</span> ( <span class="type"><a href="qgraphicsscenehoverevent.html">QGraphicsSceneHoverEvent</a></span> * <i>event</i> )<tt> [virtual protected]</tt></h3> <p>Reimplemented from <a href="qgraphicsitem.html#hoverMoveEvent">QGraphicsItem::hoverMoveEvent</a>().</p> <!-- @@@hoverMoveEvent --> <!-- $$$inputMethodEvent[overload1]$$$inputMethodEventQInputMethodEvent* --> <h3 class="fn"><a name="inputMethodEvent"></a><span class="type">void</span> QGraphicsTextItem::<span class="name">inputMethodEvent</span> ( <span class="type"><a href="qinputmethodevent.html">QInputMethodEvent</a></span> * <i>event</i> )<tt> [virtual protected]</tt></h3> <p>Reimplemented from <a href="qgraphicsitem.html#inputMethodEvent">QGraphicsItem::inputMethodEvent</a>().</p> <!-- @@@inputMethodEvent --> <!-- $$$inputMethodQuery[overload1]$$$inputMethodQueryQt::InputMethodQuery --> <h3 class="fn"><a name="inputMethodQuery"></a><span class="type"><a href="qvariant.html">QVariant</a></span> QGraphicsTextItem::<span class="name">inputMethodQuery</span> ( <span class="type"><a href="qt.html#InputMethodQuery-enum">Qt::InputMethodQuery</a></span> <i>query</i> ) const<tt> [virtual protected]</tt></h3> <p>Reimplemented from <a href="qgraphicsitem.html#inputMethodQuery">QGraphicsItem::inputMethodQuery</a>().</p> <!-- @@@inputMethodQuery --> <!-- $$$isObscuredBy[overload1]$$$isObscuredByconstQGraphicsItem* --> <h3 class="fn"><a name="isObscuredBy"></a><span class="type">bool</span> QGraphicsTextItem::<span class="name">isObscuredBy</span> ( const <span class="type"><a href="qgraphicsitem.html">QGraphicsItem</a></span> * <i>item</i> ) const<tt> [virtual]</tt></h3> <p>Reimplemented from <a href="qgraphicsitem.html#isObscuredBy">QGraphicsItem::isObscuredBy</a>().</p> <!-- @@@isObscuredBy --> <!-- $$$keyPressEvent[overload1]$$$keyPressEventQKeyEvent* --> <h3 class="fn"><a name="keyPressEvent"></a><span class="type">void</span> QGraphicsTextItem::<span class="name">keyPressEvent</span> ( <span class="type"><a href="qkeyevent.html">QKeyEvent</a></span> * <i>event</i> )<tt> [virtual protected]</tt></h3> <p>Reimplemented from <a href="qgraphicsitem.html#keyPressEvent">QGraphicsItem::keyPressEvent</a>().</p> <!-- @@@keyPressEvent --> <!-- $$$keyReleaseEvent[overload1]$$$keyReleaseEventQKeyEvent* --> <h3 class="fn"><a name="keyReleaseEvent"></a><span class="type">void</span> QGraphicsTextItem::<span class="name">keyReleaseEvent</span> ( <span class="type"><a href="qkeyevent.html">QKeyEvent</a></span> * <i>event</i> )<tt> [virtual protected]</tt></h3> <p>Reimplemented from <a href="qgraphicsitem.html#keyReleaseEvent">QGraphicsItem::keyReleaseEvent</a>().</p> <!-- @@@keyReleaseEvent --> <!-- $$$linkActivated[overload1]$$$linkActivatedconstQString& --> <h3 class="fn"><a name="linkActivated"></a><span class="type">void</span> QGraphicsTextItem::<span class="name">linkActivated</span> ( const <span class="type"><a href="qstring.html">QString</a></span> & <i>link</i> )<tt> [signal]</tt></h3> <p>This signal is emitted when the user clicks on a link on a text item that enables <a href="qt.html#TextInteractionFlag-enum">Qt::LinksAccessibleByMouse</a> or <a href="qt.html#TextInteractionFlag-enum">Qt::LinksAccessibleByKeyboard</a>. <i>link</i> is the link that was clicked.</p> <p><b>See also </b><a href="qgraphicstextitem.html#setTextInteractionFlags">setTextInteractionFlags</a>().</p> <!-- @@@linkActivated --> <!-- $$$linkHovered[overload1]$$$linkHoveredconstQString& --> <h3 class="fn"><a name="linkHovered"></a><span class="type">void</span> QGraphicsTextItem::<span class="name">linkHovered</span> ( const <span class="type"><a href="qstring.html">QString</a></span> & <i>link</i> )<tt> [signal]</tt></h3> <p>This signal is emitted when the user hovers over a link on a text item that enables <a href="qt.html#TextInteractionFlag-enum">Qt::LinksAccessibleByMouse</a>. <i>link</i> is the link that was hovered over.</p> <p><b>See also </b><a href="qgraphicstextitem.html#setTextInteractionFlags">setTextInteractionFlags</a>().</p> <!-- @@@linkHovered --> <!-- $$$mouseDoubleClickEvent[overload1]$$$mouseDoubleClickEventQGraphicsSceneMouseEvent* --> <h3 class="fn"><a name="mouseDoubleClickEvent"></a><span class="type">void</span> QGraphicsTextItem::<span class="name">mouseDoubleClickEvent</span> ( <span class="type"><a href="qgraphicsscenemouseevent.html">QGraphicsSceneMouseEvent</a></span> * <i>event</i> )<tt> [virtual protected]</tt></h3> <p>Reimplemented from <a href="qgraphicsitem.html#mouseDoubleClickEvent">QGraphicsItem::mouseDoubleClickEvent</a>().</p> <!-- @@@mouseDoubleClickEvent --> <!-- $$$mouseMoveEvent[overload1]$$$mouseMoveEventQGraphicsSceneMouseEvent* --> <h3 class="fn"><a name="mouseMoveEvent"></a><span class="type">void</span> QGraphicsTextItem::<span class="name">mouseMoveEvent</span> ( <span class="type"><a href="qgraphicsscenemouseevent.html">QGraphicsSceneMouseEvent</a></span> * <i>event</i> )<tt> [virtual protected]</tt></h3> <p>Reimplemented from <a href="qgraphicsitem.html#mouseMoveEvent">QGraphicsItem::mouseMoveEvent</a>().</p> <!-- @@@mouseMoveEvent --> <!-- $$$mousePressEvent[overload1]$$$mousePressEventQGraphicsSceneMouseEvent* --> <h3 class="fn"><a name="mousePressEvent"></a><span class="type">void</span> QGraphicsTextItem::<span class="name">mousePressEvent</span> ( <span class="type"><a href="qgraphicsscenemouseevent.html">QGraphicsSceneMouseEvent</a></span> * <i>event</i> )<tt> [virtual protected]</tt></h3> <p>Reimplemented from <a href="qgraphicsitem.html#mousePressEvent">QGraphicsItem::mousePressEvent</a>().</p> <!-- @@@mousePressEvent --> <!-- $$$mouseReleaseEvent[overload1]$$$mouseReleaseEventQGraphicsSceneMouseEvent* --> <h3 class="fn"><a name="mouseReleaseEvent"></a><span class="type">void</span> QGraphicsTextItem::<span class="name">mouseReleaseEvent</span> ( <span class="type"><a href="qgraphicsscenemouseevent.html">QGraphicsSceneMouseEvent</a></span> * <i>event</i> )<tt> [virtual protected]</tt></h3> <p>Reimplemented from <a href="qgraphicsitem.html#mouseReleaseEvent">QGraphicsItem::mouseReleaseEvent</a>().</p> <!-- @@@mouseReleaseEvent --> <!-- $$$opaqueArea[overload1]$$$opaqueArea --> <h3 class="fn"><a name="opaqueArea"></a><span class="type"><a href="qpainterpath.html">QPainterPath</a></span> QGraphicsTextItem::<span class="name">opaqueArea</span> () const<tt> [virtual]</tt></h3> <p>Reimplemented from <a href="qgraphicsitem.html#opaqueArea">QGraphicsItem::opaqueArea</a>().</p> <!-- @@@opaqueArea --> <!-- $$$paint[overload1]$$$paintQPainter*constQStyleOptionGraphicsItem*QWidget* --> <h3 class="fn"><a name="paint"></a><span class="type">void</span> QGraphicsTextItem::<span class="name">paint</span> ( <span class="type"><a href="qpainter.html">QPainter</a></span> * <i>painter</i>, const <span class="type"><a href="qstyleoptiongraphicsitem.html">QStyleOptionGraphicsItem</a></span> * <i>option</i>, <span class="type"><a href="qwidget.html">QWidget</a></span> * <i>widget</i> )<tt> [virtual]</tt></h3> <p>Reimplemented from <a href="qgraphicsitem.html#paint">QGraphicsItem::paint</a>().</p> <!-- @@@paint --> <!-- $$$sceneEvent[overload1]$$$sceneEventQEvent* --> <h3 class="fn"><a name="sceneEvent"></a><span class="type">bool</span> QGraphicsTextItem::<span class="name">sceneEvent</span> ( <span class="type"><a href="qevent.html">QEvent</a></span> * <i>event</i> )<tt> [virtual protected]</tt></h3> <p>Reimplemented from <a href="qgraphicsitem.html#sceneEvent">QGraphicsItem::sceneEvent</a>().</p> <!-- @@@sceneEvent --> <!-- $$$setDefaultTextColor[overload1]$$$setDefaultTextColorconstQColor& --> <h3 class="fn"><a name="setDefaultTextColor"></a><span class="type">void</span> QGraphicsTextItem::<span class="name">setDefaultTextColor</span> ( const <span class="type"><a href="qcolor.html">QColor</a></span> & <i>col</i> )</h3> <p>Sets the color for unformatted text to <i>col</i>.</p> <p><b>See also </b><a href="qgraphicstextitem.html#defaultTextColor">defaultTextColor</a>().</p> <!-- @@@setDefaultTextColor --> <!-- $$$setDocument[overload1]$$$setDocumentQTextDocument* --> <h3 class="fn"><a name="setDocument"></a><span class="type">void</span> QGraphicsTextItem::<span class="name">setDocument</span> ( <span class="type"><a href="qtextdocument.html">QTextDocument</a></span> * <i>document</i> )</h3> <p>Sets the text document <i>document</i> on the item.</p> <p><b>See also </b><a href="qgraphicstextitem.html#document">document</a>().</p> <!-- @@@setDocument --> <!-- $$$setFont[overload1]$$$setFontconstQFont& --> <h3 class="fn"><a name="setFont"></a><span class="type">void</span> QGraphicsTextItem::<span class="name">setFont</span> ( const <span class="type"><a href="qfont.html">QFont</a></span> & <i>font</i> )</h3> <p>Sets the font used to render the text item to <i>font</i>.</p> <p><b>See also </b><a href="qgraphicstextitem.html#font">font</a>().</p> <!-- @@@setFont --> <!-- $$$setHtml[overload1]$$$setHtmlconstQString& --> <h3 class="fn"><a name="setHtml"></a><span class="type">void</span> QGraphicsTextItem::<span class="name">setHtml</span> ( const <span class="type"><a href="qstring.html">QString</a></span> & <i>text</i> )</h3> <p>Sets the item's text to <i>text</i>, assuming that text is HTML formatted. If the item has keyboard input focus, this function will also call <a href="qgraphicsitem.html#ensureVisible">ensureVisible</a>() to ensure that the text is visible in all viewports.</p> <p><b>See also </b><a href="qgraphicstextitem.html#toHtml">toHtml</a>(), <a href="qgraphicsitem.html#hasFocus">hasFocus</a>(), and <a href="qgraphicssimpletextitem.html">QGraphicsSimpleTextItem</a>.</p> <!-- @@@setHtml --> <!-- $$$setPlainText[overload1]$$$setPlainTextconstQString& --> <h3 class="fn"><a name="setPlainText"></a><span class="type">void</span> QGraphicsTextItem::<span class="name">setPlainText</span> ( const <span class="type"><a href="qstring.html">QString</a></span> & <i>text</i> )</h3> <p>Sets the item's text to <i>text</i>. If the item has keyboard input focus, this function will also call <a href="qgraphicsitem.html#ensureVisible">ensureVisible</a>() to ensure that the text is visible in all viewports.</p> <p><b>See also </b><a href="qgraphicstextitem.html#toHtml">toHtml</a>() and <a href="qgraphicsitem.html#hasFocus">hasFocus</a>().</p> <!-- @@@setPlainText --> <!-- $$$setTabChangesFocus[overload1]$$$setTabChangesFocusbool --> <h3 class="fn"><a name="setTabChangesFocus"></a><span class="type">void</span> QGraphicsTextItem::<span class="name">setTabChangesFocus</span> ( <span class="type">bool</span> <i>b</i> )</h3> <p>If <i>b</i> is true, the <b>Tab</b> key will cause the widget to change focus; otherwise, the tab key will insert a tab into the document.</p> <p>In some occasions text edits should not allow the user to input tabulators or change indentation using the <b>Tab</b> key, as this breaks the focus chain. The default is false.</p> <p>This function was introduced in Qt 4.5.</p> <p><b>See also </b><a href="qgraphicstextitem.html#tabChangesFocus">tabChangesFocus</a>(), <a href="qgraphicsitem.html#GraphicsItemFlag-enum">ItemIsFocusable</a>, and <a href="qgraphicstextitem.html#textInteractionFlags">textInteractionFlags</a>().</p> <!-- @@@setTabChangesFocus --> <!-- $$$setTextInteractionFlags[overload1]$$$setTextInteractionFlagsQt::TextInteractionFlags --> <h3 class="fn"><a name="setTextInteractionFlags"></a><span class="type">void</span> QGraphicsTextItem::<span class="name">setTextInteractionFlags</span> ( <span class="type"><a href="qt.html#TextInteractionFlag-enum">Qt::TextInteractionFlags</a></span> <i>flags</i> )</h3> <p>Sets the flags <i>flags</i> to specify how the text item should react to user input.</p> <p>The default for a <a href="qgraphicstextitem.html">QGraphicsTextItem</a> is <a href="qt.html#TextInteractionFlag-enum">Qt::NoTextInteraction</a>. This function also affects the <a href="qgraphicsitem.html#GraphicsItemFlag-enum">ItemIsFocusable</a> <a href="qgraphicsitem.html">QGraphicsItem</a> flag by setting it if <i>flags</i> is different from <a href="qt.html#TextInteractionFlag-enum">Qt::NoTextInteraction</a> and clearing it otherwise.</p> <p>By default, the text is read-only. To transform the item into an editor, set the <a href="qt.html#TextInteractionFlag-enum">Qt::TextEditable</a> flag.</p> <p><b>See also </b><a href="qgraphicstextitem.html#textInteractionFlags">textInteractionFlags</a>().</p> <!-- @@@setTextInteractionFlags --> <!-- $$$setTextWidth[overload1]$$$setTextWidthqreal --> <h3 class="fn"><a name="setTextWidth"></a><span class="type">void</span> QGraphicsTextItem::<span class="name">setTextWidth</span> ( <span class="type"><a href="qtglobal.html#qreal-typedef">qreal</a></span> <i>width</i> )</h3> <p>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.</p> <p>If <i>width</i> 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.</p> <p>The default value is -1.</p> <p>Note that <a href="qgraphicstextitem.html">QGraphicsTextItem</a> keeps a <a href="qtextdocument.html">QTextDocument</a> internally, which is used to calculate the text width.</p> <p><b>See also </b><a href="qgraphicstextitem.html#textWidth">textWidth</a>() and <a href="qtextdocument.html#textWidth-prop">QTextDocument::setTextWidth</a>().</p> <!-- @@@setTextWidth --> <!-- $$$shape[overload1]$$$shape --> <h3 class="fn"><a name="shape"></a><span class="type"><a href="qpainterpath.html">QPainterPath</a></span> QGraphicsTextItem::<span class="name">shape</span> () const<tt> [virtual]</tt></h3> <p>Reimplemented from <a href="qgraphicsitem.html#shape">QGraphicsItem::shape</a>().</p> <!-- @@@shape --> <!-- $$$tabChangesFocus[overload1]$$$tabChangesFocus --> <h3 class="fn"><a name="tabChangesFocus"></a><span class="type">bool</span> QGraphicsTextItem::<span class="name">tabChangesFocus</span> () const</h3> <p>Returns true if the <b>Tab</b> key will cause the widget to change focus; otherwise, false is returned.</p> <p>By default, this behavior is disabled, and this function will return false.</p> <p>This function was introduced in Qt 4.5.</p> <p><b>See also </b><a href="qgraphicstextitem.html#setTabChangesFocus">setTabChangesFocus</a>().</p> <!-- @@@tabChangesFocus --> <!-- $$$textInteractionFlags[overload1]$$$textInteractionFlags --> <h3 class="fn"><a name="textInteractionFlags"></a><span class="type"><a href="qt.html#TextInteractionFlag-enum">Qt::TextInteractionFlags</a></span> QGraphicsTextItem::<span class="name">textInteractionFlags</span> () const</h3> <p>Returns the current text interaction flags.</p> <p><b>See also </b><a href="qgraphicstextitem.html#setTextInteractionFlags">setTextInteractionFlags</a>().</p> <!-- @@@textInteractionFlags --> <!-- $$$textWidth[overload1]$$$textWidth --> <h3 class="fn"><a name="textWidth"></a><span class="type"><a href="qtglobal.html#qreal-typedef">qreal</a></span> QGraphicsTextItem::<span class="name">textWidth</span> () const</h3> <p>Returns the text width.</p> <p>The width is calculated with the <a href="qtextdocument.html">QTextDocument</a> that <a href="qgraphicstextitem.html">QGraphicsTextItem</a> keeps internally.</p> <p><b>See also </b><a href="qgraphicstextitem.html#setTextWidth">setTextWidth</a>() and <a href="qtextdocument.html#textWidth-prop">QTextDocument::textWidth</a>().</p> <!-- @@@textWidth --> <!-- $$$toHtml[overload1]$$$toHtml --> <h3 class="fn"><a name="toHtml"></a><span class="type"><a href="qstring.html">QString</a></span> QGraphicsTextItem::<span class="name">toHtml</span> () const</h3> <p>Returns the item's text converted to HTML, or an empty <a href="qstring.html">QString</a> if no text has been set.</p> <p><b>See also </b><a href="qgraphicstextitem.html#setHtml">setHtml</a>().</p> <!-- @@@toHtml --> <!-- $$$toPlainText[overload1]$$$toPlainText --> <h3 class="fn"><a name="toPlainText"></a><span class="type"><a href="qstring.html">QString</a></span> QGraphicsTextItem::<span class="name">toPlainText</span> () const</h3> <p>Returns the item's text converted to plain text, or an empty <a href="qstring.html">QString</a> if no text has been set.</p> <p><b>See also </b><a href="qgraphicstextitem.html#setPlainText">setPlainText</a>().</p> <!-- @@@toPlainText --> <!-- $$$type[overload1]$$$type --> <h3 class="fn"><a name="type"></a><span class="type">int</span> QGraphicsTextItem::<span class="name">type</span> () const<tt> [virtual]</tt></h3> <p>Reimplemented from <a href="qgraphicsitem.html#type">QGraphicsItem::type</a>().</p> <!-- @@@type --> </div> </div> </div> </div> <div class="ft"> <span></span> </div> </div> <div class="footer"> <p> <acronym title="Copyright">©</acronym> 2013 Digia Plc and/or its subsidiaries. Documentation contributions included herein are the copyrights of their respective owners.</p> <br /> <p> The documentation provided herein is licensed under the terms of the <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation License version 1.3</a> as published by the Free Software Foundation.</p> <p> Documentation sources may be obtained from <a href="http://www.qt-project.org"> www.qt-project.org</a>.</p> <br /> <p> Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide. All other trademarks are property of their respective owners. <a title="Privacy Policy" href="http://en.gitorious.org/privacy_policy/">Privacy Policy</a></p> </div> <script src="scripts/functions.js" type="text/javascript"></script> </body> </html>