QTextOption Class

The QTextOption class provides a description of general rich text properties. More...

Header: #include <QTextOption>
qmake: QT += gui

Note: All functions in this class are reentrant.

Public Types

Tab
enum Flag { IncludeTrailingSpaces, ShowTabsAndSpaces, ShowLineAndParagraphSeparators, ShowDocumentTerminator, AddSpaceForLineAndParagraphSeparators, SuppressColors }
flags Flags
enum TabType { LeftTab, RightTab, CenterTab, DelimiterTab }
enum WrapMode { NoWrap, WordWrap, ManualWrap, WrapAnywhere, WrapAtWordBoundaryOrAnywhere }

Public Functions

QTextOption(Qt::Alignment alignment)
QTextOption()
~QTextOption()
void setTabArray(const QList<qreal> &tabStops)
void setTabs(const QList<QTextOption::Tab> &tabStops)
QList<qreal> tabArray() const

Detailed Description

QTextOption is used to encapsulate common rich text properties in a single object. It contains information about text alignment, layout direction, word wrapping, and other standard properties associated with text rendering and layout.

See also QTextEdit, QTextDocument, and QTextCursor.

Member Type Documentation

enum QTextOption::Flag
flags QTextOption::Flags

ConstantValueDescription
QTextOption::IncludeTrailingSpaces0x80000000When this option is set, QTextLine::naturalTextWidth() and naturalTextRect() will return a value that includes the width of trailing spaces in the text; otherwise this width is excluded.
QTextOption::ShowTabsAndSpaces0x1Visualize spaces with little dots, and tabs with little arrows. Non-breaking spaces are shown differently to breaking spaces.
QTextOption::ShowLineAndParagraphSeparators0x2Visualize line and paragraph separators with appropriate symbol characters.
QTextOption::ShowDocumentTerminator0x10Visualize the end of the document with a section sign. This enum value was added in Qt 5.7.
QTextOption::AddSpaceForLineAndParagraphSeparators0x4While determining the line-break positions take into account the space added for drawing a separator character.
QTextOption::SuppressColors0x8Suppress all color changes in the character formats (except the main selection).

The Flags type is a typedef for QFlags<Flag>. It stores an OR combination of Flag values.

enum QTextOption::TabType

This enum holds the different types of tabulator

ConstantValueDescription
QTextOption::LeftTab0A left-tab
QTextOption::RightTab1A right-tab
QTextOption::CenterTab2A centered-tab
QTextOption::DelimiterTab3A tab stopping at a certain delimiter-character

This enum was introduced or modified in Qt 4.4.

enum QTextOption::WrapMode

This enum describes how text is wrapped in a document.

ConstantValueDescription
QTextOption::NoWrap0Text is not wrapped at all.
QTextOption::WordWrap1Text is wrapped at word boundaries.
QTextOption::ManualWrap2Same as QTextOption::NoWrap
QTextOption::WrapAnywhere3Text can be wrapped at any point on a line, even if it occurs in the middle of a word.
QTextOption::WrapAtWordBoundaryOrAnywhere4If possible, wrapping occurs at a word boundary; otherwise it will occur at the appropriate point on the line, even in the middle of a word.

Member Function Documentation

QTextOption::QTextOption(Qt::Alignment alignment)

Constructs a text option with the given alignment for text. The word wrap property is set to QTextOption::WordWrap. The using of design metrics flag is set to false.

QTextOption::QTextOption()

Constructs a text option with default properties for text. The text alignment property is set to Qt::AlignLeft. The word wrap property is set to QTextOption::WordWrap. The using of design metrics flag is set to false.

QTextOption::~QTextOption()

Destroys the text option.

void QTextOption::setTabArray(const QList<qreal> &tabStops)

Sets the tab positions for the text layout to those specified by tabStops.

See also tabArray(), setTabStopDistance(), and setTabs().

void QTextOption::setTabs(const QList<QTextOption::Tab> &tabStops)

Sets the tab positions for the text layout to those specified by tabStops.

This function was introduced in Qt 4.4.

See also tabStop().

QList<qreal> QTextOption::tabArray() const

Returns a list of tab positions defined for the text layout.

See also setTabArray() and tabStop().