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  ·  Toutes les fonctions  ·  Vues d'ensemble  · 

QTextCharFormat Class Reference
[QtGui module]

The QTextCharFormat class provides formatting information for characters in a QTextDocument. More...

 #include <QTextCharFormat>

Inherits QTextFormat.

Inherited by QTextImageFormat and QTextTableCellFormat.

Note: All the functions in this class are reentrant.

Public Types

  • enum UnderlineStyle { NoUnderline, SingleUnderline, DashUnderline, DotLine, ..., SpellCheckUnderline }
  • enum VerticalAlignment { AlignNormal, AlignSuperScript, AlignSubScript, AlignMiddle, AlignBottom, AlignTop }

Public Functions


Detailed Description

The QTextCharFormat class provides formatting information for characters in a QTextDocument.

The character format of text in a document specifies the visual properties of the text, as well as information about its role in a hypertext document.

The font used can be set by supplying a font to the setFont() function, and each aspect of its appearance can be adjusted to give the desired effect. setFontFamily() and setFontPointSize() define the font's family (e.g. Times) and printed size; setFontWeight() and setFontItalic() provide control over the style of the font. setFontUnderline(), setFontOverline(), setFontStrikeOut(), and setFontFixedPitch() provide additional effects for text.

The color is set with setForeground(). If the text is intended to be used as an anchor (for hyperlinks), this can be enabled with setAnchor(). The setAnchorHref() and setAnchorNames() functions are used to specify the information about the hyperlink's destination and the anchor's name.

See also QTextFormat, QTextBlockFormat, QTextTableFormat, and QTextListFormat.


Member Type Documentation

enum QTextCharFormat::UnderlineStyle

This enum describes the different ways drawing underlined text.

ConstantValueDescription
QTextCharFormat::NoUnderline0Text is draw without any underlining decoration.
QTextCharFormat::SingleUnderline1A line is drawn using Qt::SolidLine.
QTextCharFormat::DashUnderline2Dashes are drawn using Qt::DashLine.
QTextCharFormat::DotLine3Dots are drawn using Qt::DotLine;
QTextCharFormat::DashDotLine4Dashs and dots are drawn using Qt::DashDotLine.
QTextCharFormat::DashDotDotLine5Underlines draw drawn using Qt::DashDotDotLine.
QTextCharFormat::WaveUnderline6The text is underlined using a wave shaped line.
QTextCharFormat::SpellCheckUnderline7The underline is drawn depending on the QStyle::SH_SpellCeckUnderlineStyle style hint of the QApplication style. By default this is mapped to WaveUnderline, on Mac OS X it is mapped to DashDotLine.

See also Qt::PenStyle.

enum QTextCharFormat::VerticalAlignment

This enum describes the ways that adjacent characters can be vertically aligned.

ConstantValueDescription
QTextCharFormat::AlignNormal0Adjacent characters are positioned in the standard way for text in the writing system in use.
QTextCharFormat::AlignSuperScript1Characters are placed above the baseline for normal text.
QTextCharFormat::AlignSubScript2Characters are placed below the baseline for normal text.
QTextCharFormat::AlignMiddle3This is currently only implemented for inline objects. The center of the object is vertically aligned with the base line.
QTextCharFormat::AlignBottom5The bottom edge of the object is vertically aligned with the base line.
QTextCharFormat::AlignTop4The top edge of the object is vertically aligned with the base line.


Member Function Documentation

QTextCharFormat::QTextCharFormat ()

Constructs a new character format object.

QString QTextCharFormat::anchorHref () const

Returns the text format's hypertext link, or an empty string if none has been set.

See also setAnchorHref().

QStringList QTextCharFormat::anchorNames () const

Returns the anchor names associated with this text format, or an empty string list if none has been set. If the anchor names are set, text with this format can be the destination of a hypertext link.

This function was introduced in Qt 4.3.

See also setAnchorNames().

QFont QTextCharFormat::font () const

Returns the font for this character format.

See also setFont().

QFont::Capitalization QTextCharFormat::fontCapitalization () const

Returns the current capitalization type of the font.

This function was introduced in Qt 4.4.

See also setFontCapitalization().

QString QTextCharFormat::fontFamily () const

Returns the text format's font family.

See also setFontFamily() and font().

bool QTextCharFormat::fontFixedPitch () const

Returns true if the text format's font is fixed pitch; otherwise returns false.

See also setFontFixedPitch() and font().

bool QTextCharFormat::fontItalic () const

Returns true if the text format's font is italic; otherwise returns false.

See also setFontItalic() and font().

qreal QTextCharFormat::fontLetterSpacing () const

Returns the current letter spacing percentage.

This function was introduced in Qt 4.4.

See also setFontLetterSpacing().

bool QTextCharFormat::fontOverline () const

Returns true if the text format's font is overlined; otherwise returns false.

See also setFontOverline() and font().

qreal QTextCharFormat::fontPointSize () const

Returns the font size used to display text in this format.

See also setFontPointSize() and font().

bool QTextCharFormat::fontStrikeOut () const

Returns true if the text format's font is struck out (has a horizontal line drawn through it); otherwise returns false.

See also setFontStrikeOut() and font().

bool QTextCharFormat::fontUnderline () const

Returns true if the text format's font is underlined; otherwise returns false.

See also setFontUnderline() and font().

int QTextCharFormat::fontWeight () const

Returns the text format's font weight.

See also setFontWeight(), font(), and QFont::Weight.

qreal QTextCharFormat::fontWordSpacing () const

Returns the current word spacing value.

This function was introduced in Qt 4.4.

See also setFontWordSpacing().

bool QTextCharFormat::isAnchor () const

Returns true if the text is formatted as an anchor; otherwise returns false.

See also setAnchor(), setAnchorHref(), and setAnchorNames().

bool QTextCharFormat::isValid () const

Returns true if this character format is valid; otherwise returns false.

void QTextCharFormat::setAnchor ( bool anchor )

If anchor is true, text with this format represents an anchor, and is formatted in the appropriate way; otherwise the text is formatted normally. (Anchors are hyperlinks which are often shown underlined and in a different color from plain text.)

The way the text is rendered is independent of whether or not the format has a valid anchor defined. Use setAnchorHref(), and optionally setAnchorNames() to create a hypertext link.

See also isAnchor().

void QTextCharFormat::setAnchorHref ( const QString & value )

Sets the hypertext link for the text format to the given value. This is typically a URL like "http://www.trolltech.com/index.html".

The anchor will be displayed with the value as its display text; if you want to display different text call setAnchorNames().

To format the text as a hypertext link use setAnchor().

See also anchorHref().

void QTextCharFormat::setAnchorNames ( const QStringList & names )

Sets the text format's anchor names. For the anchor to work as a hyperlink, the destination must be set with setAnchorHref() and the anchor must be enabled with setAnchor().

This function was introduced in Qt 4.3.

See also anchorNames().

void QTextCharFormat::setFont ( const QFont & font )

Sets the text format's font.

See also font().

void QTextCharFormat::setFontCapitalization ( QFont::Capitalization capitalization )

Sets the capitalization of the text that apppears in this font to capitalization.

A font's capitalization makes the text appear in the selected capitalization mode.

This function was introduced in Qt 4.4.

See also fontCapitalization().

void QTextCharFormat::setFontFamily ( const QString & family )

Sets the text format's font family.

See also fontFamily() and setFont().

void QTextCharFormat::setFontFixedPitch ( bool fixedPitch )

If fixedPitch is true, sets the text format's font to be fixed pitch; otherwise a non-fixed pitch font is used.

See also fontFixedPitch() and setFont().

void QTextCharFormat::setFontItalic ( bool italic )

If italic is true, sets the text format's font to be italic; otherwise the font will be non-italic.

See also fontItalic() and setFont().

void QTextCharFormat::setFontLetterSpacing ( qreal spacing )

Sets the letter spacing of this format to the given spacing, in percent. A value of 100 indicates default spacing; a value of 200 doubles the amount of space a letter takes.

This function was introduced in Qt 4.4.

See also fontLetterSpacing().

void QTextCharFormat::setFontOverline ( bool overline )

If overline is true, sets the text format's font to be overlined; otherwise the font is displayed non-overlined.

See also fontOverline() and setFont().

void QTextCharFormat::setFontPointSize ( qreal size )

Sets the text format's font size.

See also fontPointSize() and setFont().

void QTextCharFormat::setFontStrikeOut ( bool strikeOut )

If strikeOut is true, sets the text format's font with strike-out enabled (with a horizontal line through it); otherwise it is displayed without strikeout.

See also fontStrikeOut() and setFont().

void QTextCharFormat::setFontUnderline ( bool underline )

If underline is true, sets the text format's font to be underlined; otherwise it is displayed non-underlined.

See also fontUnderline() and setFont().

void QTextCharFormat::setFontWeight ( int weight )

Sets the text format's font weight to weight.

See also fontWeight(), setFont(), and QFont::Weight.

void QTextCharFormat::setFontWordSpacing ( qreal spacing )

Sets the word spacing of this format to the given spacing, in pixels.

This function was introduced in Qt 4.4.

See also fontWordSpacing().

void QTextCharFormat::setTextOutline ( const QPen & pen )

Sets the pen used to draw the outlines of characters to the given pen.

See also textOutline().

void QTextCharFormat::setToolTip ( const QString & text )

Sets the tool tip for a fragment of text to the given text.

This function was introduced in Qt 4.3.

See also toolTip().

void QTextCharFormat::setUnderlineColor ( const QColor & color )

Sets the underline color used for the characters with this format to the color specified.

See also underlineColor().

void QTextCharFormat::setUnderlineStyle ( UnderlineStyle style )

Sets the style of underlining the text to style.

This function was introduced in Qt 4.2.

See also underlineStyle().

void QTextCharFormat::setVerticalAlignment ( VerticalAlignment alignment )

Sets the vertical alignment used for the characters with this format to the alignment specified.

See also verticalAlignment().

QPen QTextCharFormat::textOutline () const

Returns the pen used to draw the outlines of characters in this format.

See also setTextOutline().

QString QTextCharFormat::toolTip () const

Returns the tool tip that is displayed for a fragment of text.

This function was introduced in Qt 4.3.

See also setToolTip().

QColor QTextCharFormat::underlineColor () const

Returns the color used to underline the characters with this format.

See also setUnderlineColor().

UnderlineStyle QTextCharFormat::underlineStyle () const

Returns the style of underlining the text.

This function was introduced in Qt 4.2.

See also setUnderlineStyle().

VerticalAlignment QTextCharFormat::verticalAlignment () const

Returns the vertical alignment used for characters with this format.

See also setVerticalAlignment().

Publicité

Best Of

Actualités les plus lues

Semaine
Mois
Année
  1. «Le projet de loi des droits du développeur» : quelles conditions doivent remplir les entreprises pour que le développeur puisse réussir ? 72
  2. Les développeurs détestent-ils les antivirus ? Un programmeur manifeste sa haine envers ces solutions de sécurité 27
  3. Une nouvelle ère d'IHM 3D pour les automobiles, un concept proposé par Digia et implémenté avec Qt 3
  4. Qt Creator 2.5 est sorti en beta, l'EDI supporte maintenant plus de fonctionnalités de C++11 2
  5. Vingt sociétés montrent leurs décodeurs basés sur Qt au IPTV World Forum, en en exploitant diverses facettes (déclaratif, Web, widgets) 0
  6. PySide devient un add-on Qt et rejoint le Qt Project et le modèle d'open gouvernance 1
  7. Thread travailleur avec Qt en utilisant les signaux et les slots, un article de Christophe Dumez traduit par Thibaut Cuvelier 1
  1. « Quelque chose ne va vraiment pas avec les développeurs "modernes" », un développeur à "l'ancienne" critique la multiplication des bibliothèques 101
  2. Pourquoi les programmeurs sont-ils moins payés que les gestionnaires de programmes ? Manquent-ils de pouvoir de négociation ? 51
  3. «Le projet de loi des droits du développeur» : quelles conditions doivent remplir les entreprises pour que le développeur puisse réussir ? 69
  4. Les développeurs détestent-ils les antivirus ? Un programmeur manifeste sa haine envers ces solutions de sécurité 27
  5. Qt Commercial : Digia organise un webinar gratuit le 27 mars sur la conception d'interfaces utilisateur et d'applications avec le framework 0
  6. Quelles nouveautés de C++11 Visual C++ doit-il rapidement intégrer ? Donnez-nous votre avis 10
  7. 2017 : un quinquennat pour une nouvelle version du C++ ? Possible, selon Herb Sutter 11
Page suivante
  1. Linus Torvalds : le "C++ est un langage horrible", en justifiant le choix du C pour le système de gestion de version Git 100
  2. Comment prendre en compte l'utilisateur dans vos applications ? Pour un développeur, « 90 % des utilisateurs sont des idiots » 229
  3. Quel est LE livre que tout développeur doit lire absolument ? Celui qui vous a le plus marqué et inspiré 96
  4. Apple cède et s'engage à payer des droits à Nokia, le conflit des brevets entre les deux firmes s'achève 158
  5. Nokia porte à nouveau plainte contre Apple pour violation de sept nouveaux brevets 158
  6. Quel est le code dont vous êtes le plus fier ? Pourquoi l'avez-vous écrit ? Et pourquoi vous a-t-il donné autant de satisfaction ? 83
  7. « Quelque chose ne va vraiment pas avec les développeurs "modernes" », un développeur à "l'ancienne" critique la multiplication des bibliothèques 101
Page suivante

Le Qt Labs au hasard

Logo

Le moteur de rendu OpenGL

Les Qt Labs sont les laboratoires des développeurs de Qt, où ils peuvent partager des impressions sur le framework, son utilisation, ce que pourrait être son futur. 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 qtextended4.4
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