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  · 

QTextLine Class Reference
[QtGui module]

The QTextLine class represents a line of text inside a QTextLayout. More...

 #include <QTextLine>

Note: All functions in this class are reentrant.


Public Types

enum CursorPosition { CursorBetweenCharacters, CursorOnCharacter }
enum Edge { Leading, Trailing }

Public Functions

QTextLine ()
qreal ascent () const
qreal cursorToX ( int * cursorPos, Edge edge = Leading ) const
qreal cursorToX ( int cursorPos, Edge edge = Leading ) const
qreal descent () const
void draw ( QPainter * painter, const QPointF & position, const QTextLayout::FormatRange * selection = 0 ) const
qreal height () const
bool isValid () const
qreal leading () const
bool leadingIncluded () const
int lineNumber () const
QRectF naturalTextRect () const
qreal naturalTextWidth () const
QPointF position () const
QRectF rect () const
void setLeadingIncluded ( bool included )
void setLineWidth ( qreal width )
void setNumColumns ( int numColumns )
void setNumColumns ( int numColumns, qreal alignmentWidth )
void setPosition ( const QPointF & pos )
int textLength () const
int textStart () const
qreal width () const
qreal x () const
int xToCursor ( qreal x, CursorPosition cpos = CursorBetweenCharacters ) const
qreal y () const

Detailed Description

The QTextLine class represents a line of text inside a QTextLayout.

A text line is usually created by QTextLayout::createLine().

After being created, the line can be filled using the setLineWidth() or setNumColumns() functions. A line has a number of attributes including the rectangle it occupies, rect(), its coordinates, x() and y(), its textLength(), width() and naturalTextWidth(), and its ascent() and decent() relative to the text. The position of the cursor in terms of the line is available from cursorToX() and its inverse from xToCursor(). A line can be moved with setPosition().


Member Type Documentation

enum QTextLine::CursorPosition

ConstantValue
QTextLine::CursorBetweenCharacters0
QTextLine::CursorOnCharacter1

enum QTextLine::Edge

ConstantValue
QTextLine::Leading0
QTextLine::Trailing1


Member Function Documentation

QTextLine::QTextLine ()

Creates an invalid line.

qreal QTextLine::ascent () const

Returns the line's ascent.

See also descent() and height().

qreal QTextLine::cursorToX ( int * cursorPos, Edge edge = Leading ) const

Converts the cursor position cursorPos to the corresponding x position inside the line, taking account of the edge.

If cursorPos is not a valid cursor position, the nearest valid cursor position will be used instead, and cpos will be modified to point to this valid cursor position.

See also xToCursor().

qreal QTextLine::cursorToX ( int cursorPos, Edge edge = Leading ) const

This is an overloaded function.

qreal QTextLine::descent () const

Returns the line's descent.

See also ascent() and height().

void QTextLine::draw ( QPainter * painter, const QPointF & position, const QTextLayout::FormatRange * selection = 0 ) const

Draws a line on the given painter at the specified position. The selection is reserved for internal use.

qreal QTextLine::height () const

Returns the line's height. This is equal to ascent() + descent() + 1 if leading is not included. If leading is included, this equals to ascent() + descent() + leading() + 1.

See also ascent(), descent(), leading(), and setLeadingIncluded().

bool QTextLine::isValid () const

Returns true if this text line is valid; otherwise returns false.

qreal QTextLine::leading () const

Returns the line's leading.

This function was introduced in Qt 4.6.

See also ascent(), descent(), and height().

bool QTextLine::leadingIncluded () const

Returns true if positive leading is included into the line's height; otherwise returns false.

By default, leading is not included.

This function was introduced in Qt 4.6.

See also setLeadingIncluded().

int QTextLine::lineNumber () const

Returns the position of the line in the text engine.

QRectF QTextLine::naturalTextRect () const

Returns the rectangle covered by the line.

qreal QTextLine::naturalTextWidth () const

Returns the width of the line that is occupied by text. This is always <= to width(), and is the minimum width that could be used by layout() without changing the line break position.

QPointF QTextLine::position () const

Returns the line's position relative to the text layout's position.

See also setPosition().

QRectF QTextLine::rect () const

Returns the line's bounding rectangle.

See also x(), y(), textLength(), and width().

void QTextLine::setLeadingIncluded ( bool included )

Includes positive leading into the line's height if included is true; otherwise does not include leading.

By default, leading is not included.

Note that negative leading is ignored, it must be handled in the code using the text lines by letting the lines overlap.

This function was introduced in Qt 4.6.

See also leadingIncluded().

void QTextLine::setLineWidth ( qreal width )

Lays out the line with the given width. The line is filled from its starting position with as many characters as will fit into the line. In case the text cannot be split at the end of the line, it will be filled with additional characters to the next whitespace or end of the text.

void QTextLine::setNumColumns ( int numColumns )

Lays out the line. The line is filled from its starting position with as many characters as are specified by numColumns. In case the text cannot be split until numColumns characters, the line will be filled with as many characters to the next whitespace or end of the text.

void QTextLine::setNumColumns ( int numColumns, qreal alignmentWidth )

Lays out the line. The line is filled from its starting position with as many characters as are specified by numColumns. In case the text cannot be split until numColumns characters, the line will be filled with as many characters to the next whitespace or end of the text. The provided alignmentWidth is used as reference width for alignment.

void QTextLine::setPosition ( const QPointF & pos )

Moves the line to position pos.

See also position().

int QTextLine::textLength () const

Returns the length of the text in the line.

See also naturalTextWidth().

int QTextLine::textStart () const

Returns the start of the line from the beginning of the string passed to the QTextLayout.

qreal QTextLine::width () const

Returns the line's width as specified by the layout() function.

See also naturalTextWidth(), x(), y(), textLength(), and rect().

qreal QTextLine::x () const

Returns the line's x position.

See also rect(), y(), textLength(), and width().

int QTextLine::xToCursor ( qreal x, CursorPosition cpos = CursorBetweenCharacters ) const

Converts the x-coordinate x, to the nearest matching cursor position, depending on the cursor position type, cpos.

See also cursorToX().

qreal QTextLine::y () const

Returns the line's y position.

See also x(), rect(), textLength(), and width().

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 53
  2. Les développeurs ignorent-ils trop les failles découvertes dans leur code ? Prenez-vous en compte les remarques des autres ? 17
  3. Apercevoir la troisième dimension ou l'utilisation multithreadée d'OpenGL dans Qt, un article des Qt Quarterly traduit par Guillaume Belz 0
  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 blog Digia au hasard

Logo

Déploiement d'applications Qt Commercial sur les tablettes Windows 8

Le blog Digia est l'endroit privilégié pour la communication sur l'édition commerciale de Qt, où des réponses publiques sont apportées aux questions les plus posées au support. 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.6
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