Viadeo Twitter Google Bookmarks ! Facebook Digg del.icio.us MySpace Yahoo MyWeb Blinklist Netvouz Reddit Simpy StumbleUpon Bookmarks Windows Live Favorites 
Logo Documentation Qt ·  Page d'accueil  ·  Toutes les classes  ·  Classes principales  ·  Annotées  ·  Classes groupées  ·  Modules  ·  Fonctions  · 

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

  • 1 property inherited from QObject

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

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

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


Property Documentation

openExternalLinks : bool

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

The default value is false.

Access functions:

  • bool openExternalLinks () const
  • void setOpenExternalLinks ( bool open )

textCursor : QTextCursor

This property represents the visible text cursor in an editable text item.

Access functions:

  • QTextCursor textCursor () const
  • void setTextCursor ( const QTextCursor & cursor )

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.

QColor QGraphicsTextItem::defaultTextColor () const

Returns the default text color that is used to for unformatted text.

See also setDefaultTextColor().

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 on a text item that enables Qt::LinksAccessibleByMouse or Qt::LinksAccessibleByKeyboard. link is the link that was clicked.

See also setTextInteractionFlags().

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

This signal is emitted when the user hovers over a link on a text item that enables Qt::LinksAccessibleByMouse. link is the link that was hovered over.

See also setTextInteractionFlags().

void QGraphicsTextItem::setDefaultTextColor ( const QColor & col )

Sets the color for unformatted text to col.

See also defaultTextColor().

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::setPlainText ( const QString & text )

Sets the item's text to text.

See also toHtml().

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.

By default, the text is read-only. To transform the item into an editor, set the Qt::TextEditable 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().

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

Publicité

Best Of

Actualités les plus lues

Semaine
Mois
Année
  1. « Quelque chose ne va vraiment pas avec les développeurs "modernes" », un développeur à "l'ancienne" critique la multiplication des bibliothèques 59
  2. Apercevoir la troisième dimension ou l'utilisation multithreadée d'OpenGL dans Qt, un article des Qt Quarterly traduit par Guillaume Belz 0
  3. Les développeurs ignorent-ils trop les failles découvertes dans leur code ? Prenez-vous en compte les remarques des autres ? 17
  4. BlackBerry 10 : premières images du prochain OS de RIM qui devrait intégrer des widgets et des tuiles inspirées de Windows Phone 0
  5. Quelles nouveautés de C++11 Visual C++ doit-il rapidement intégrer ? Donnez-nous votre avis 10
  6. Adieu qmake, bienvenue qbs : Qt Building Suite, un outil déclaratif et extensible pour la compilation de projets Qt 17
  7. La rubrique Qt a besoin de vous ! 1
Page suivante

Le Qt Quarterly au hasard

Logo

Générer du XML

Qt Quarterly est la revue trimestrielle proposée par Nokia et à destination des développeurs Qt. Ces articles d'une grande qualité technique sont rédigés par des experts Qt. Lire l'article.

Communauté

Ressources

Liens utiles

Contact

  • Vous souhaitez rejoindre la rédaction ou proposer un tutoriel, une traduction, une question... ? Postez dans le forum Contribuez ou contactez-nous par MP ou par email (voir en bas de page).

Qt dans le magazine

Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. Qt 4.2
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD.
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP !
 
 
 
 
Partenaires

Hébergement Web