Qt:Документация 4.3.2/qtextline

Материал из Wiki.crossplatform.ru

Перейти к: навигация, поиск
40px Внимание: Актуальная версия перевода документации находится здесь

__NOTOC__

Image:qt-logo.png

Главная · Все классы · Основные классы · Классы по группам · Модули · Функции

Image:trolltech-logo.png

Содержание

[править] QTextLine Class Reference
[модуль QtGui ]

The QTextLine class represents a line of text inside a QTextLayout. Далее...

 #include <QTextLine>

[править] Открытые типы

[править] Открытые функции


[править] Подробное описание

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


[править] Описание типов

[править]
enum QTextLine::CursorPosition

Константа Значение
QTextLine::CursorBetweenCharacters 0
QTextLine::CursorOnCharacter 1

[править]
enum QTextLine::Edge

Константа Значение
QTextLine::Leading 0
QTextLine::Trailing 1

[править] Описание функций-членов

[править]
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

Эта перегруженная функция предоставлена для удобства.

[править]
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.

See also ascent() and descent().

[править]
bool QTextLine::isValid () const

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

[править]
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::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().



Copyright © 2007 Trolltech Trademarks
Qt 4.3.2