Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
QTextOption Class Reference

\reentrant More...

#include <qtextoption.h>

+ Collaboration diagram for QTextOption:

Classes

class  Tab
 

Public Types

enum  TabType { LeftTab , RightTab , CenterTab , DelimiterTab }
 
enum  WrapMode {
  NoWrap , WordWrap , ManualWrap , WrapAnywhere ,
  WrapAtWordBoundaryOrAnywhere
}
 This enum describes how text is wrapped in a document. More...
 
enum  Flag {
  ShowTabsAndSpaces = 0x1 , ShowLineAndParagraphSeparators = 0x2 , AddSpaceForLineAndParagraphSeparators = 0x4 , SuppressColors = 0x8 ,
  ShowDocumentTerminator = 0x10 , IncludeTrailingSpaces = 0x80000000
}
 \value IncludeTrailingSpaces When 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. More...
 

Public Member Functions

 QTextOption ()
 Constructs a text option with default properties for text.
 
Q_IMPLICIT QTextOption (Qt::Alignment alignment)
 Constructs a text option with the given alignment for text.
 
 ~QTextOption ()
 Destroys the text option.
 
 QTextOption (const QTextOption &o)
 Construct a copy of the other text option.
 
QTextOptionoperator= (const QTextOption &o)
 Returns true if the text option is the same as the other text option; otherwise returns false.
 
void setAlignment (Qt::Alignment alignment)
 Sets the option's text alignment to the specified alignment.
 
Qt::Alignment alignment () const
 Returns the text alignment defined by the option.
 
void setTextDirection (Qt::LayoutDirection aDirection)
 Sets the direction of the text layout defined by the option to the given direction.
 
Qt::LayoutDirection textDirection () const
 Returns the direction of the text layout defined by the option.
 
void setWrapMode (WrapMode wrap)
 Sets the option's text wrap mode to the given mode.
 
WrapMode wrapMode () const
 Returns the text wrap mode defined by the option.
 
void setFlags (Flags flags)
 Sets the flags associated with the option to the given flags.
 
Flags flags () const
 Returns the flags associated with the option.
 
void setTabStopDistance (qreal tabStopDistance)
 
qreal tabStopDistance () const
 
void setTabArray (const QList< qreal > &tabStops)
 Sets the tab positions for the text layout to those specified by tabStops.
 
QList< qrealtabArray () const
 Returns a list of tab positions defined for the text layout.
 
void setTabs (const QList< Tab > &tabStops)
 
QList< Tabtabs () const
 
void setUseDesignMetrics (bool b)
 If enable is true then the layout will use design metrics; otherwise it will use the metrics of the paint device (which is the default behavior).
 
bool useDesignMetrics () const
 Returns true if the layout uses design rather than device metrics; otherwise returns false.
 

Detailed Description

\reentrant

The QTextOption class provides a description of general rich text properties. \inmodule QtGui

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, QTextCursor

Definition at line 17 of file qtextoption.h.

Member Enumeration Documentation

◆ Flag

\value IncludeTrailingSpaces When 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.

\value ShowTabsAndSpaces Visualize spaces with little dots, and tabs with little arrows. Non-breaking spaces are shown differently to breaking spaces. \value ShowLineAndParagraphSeparators Visualize line and paragraph separators with appropriate symbol characters. \value ShowDocumentTerminator Visualize the end of the document with a section sign. This enum value was added in Qt 5.7. \value AddSpaceForLineAndParagraphSeparators While determining the line-break positions take into account the space added for drawing a separator character. \value SuppressColors Suppress all color changes in the character formats (except the main selection).

Enumerator
ShowTabsAndSpaces 
ShowLineAndParagraphSeparators 
AddSpaceForLineAndParagraphSeparators 
SuppressColors 
ShowDocumentTerminator 
IncludeTrailingSpaces 

Definition at line 70 of file qtextoption.h.

◆ TabType

Since
4.4

This enum holds the different types of tabulator

\value LeftTab A left-tab \value RightTab A right-tab \value CenterTab A centered-tab \value DelimiterTab A tab stopping at a certain delimiter-character

Enumerator
LeftTab 
RightTab 
CenterTab 
DelimiterTab 

Definition at line 20 of file qtextoption.h.

◆ WrapMode

This enum describes how text is wrapped in a document.

\value NoWrap Text is not wrapped at all. \value WordWrap Text is wrapped at word boundaries. \value ManualWrap Same as QTextOption::NoWrap \value WrapAnywhere Text can be wrapped at any point on a line, even if it occurs in the middle of a word. \value WrapAtWordBoundaryOrAnywhere If 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.

Enumerator
NoWrap 
WordWrap 
ManualWrap 
WrapAnywhere 
WrapAtWordBoundaryOrAnywhere 

Definition at line 60 of file qtextoption.h.

Constructor & Destructor Documentation

◆ QTextOption() [1/3]

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.

Definition at line 23 of file qtextoption.cpp.

References Qt::LayoutDirectionAuto.

◆ QTextOption() [2/3]

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.

Definition at line 34 of file qtextoption.cpp.

References QGuiApplication::layoutDirection.

◆ ~QTextOption()

QTextOption::~QTextOption ( )

Destroys the text option.

Definition at line 49 of file qtextoption.cpp.

◆ QTextOption() [3/3]

QTextOption::QTextOption ( const QTextOption & o)

Construct a copy of the other text option.

Definition at line 59 of file qtextoption.cpp.

References o.

Member Function Documentation

◆ alignment()

Qt::Alignment QTextOption::alignment ( ) const
inline

Returns the text alignment defined by the option.

See also
setAlignment()

Definition at line 55 of file qtextoption.h.

Referenced by QTextDocumentLayoutPrivate::layoutBlock(), QTextDocumentLayoutPrivate::layoutFlow(), and QQuickTextPrivate::setupTextLayout().

+ Here is the caller graph for this function:

◆ flags()

Flags QTextOption::flags ( ) const
inline

Returns the flags associated with the option.

See also
setFlags()

Definition at line 80 of file qtextoption.h.

Referenced by QTextLayout::draw(), and QTextDocumentLayoutPrivate::layoutBlock().

+ Here is the caller graph for this function:

◆ operator=()

QTextOption & QTextOption::operator= ( const QTextOption & o)

Returns true if the text option is the same as the other text option; otherwise returns false.

Definition at line 79 of file qtextoption.cpp.

References o.

◆ setAlignment()

void QTextOption::setAlignment ( Qt::Alignment alignment)
inline

Sets the option's text alignment to the specified alignment.

See also
alignment()

Definition at line 107 of file qtextoption.h.

Referenced by QTextLayout::setFlags(), QQuickTextPrivate::setupTextLayout(), and QQuickTextPrivate::updateSize().

+ Here is the caller graph for this function:

◆ setFlags()

void QTextOption::setFlags ( Flags flags)
inline

Sets the flags associated with the option to the given flags.

See also
flags()

Definition at line 110 of file qtextoption.h.

◆ setTabArray()

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

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

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

Definition at line 106 of file qtextoption.cpp.

References pos, QTextOption::Tab::position, tabs(), and QTextOptionPrivate::tabStops.

+ Here is the call graph for this function:

◆ setTabs()

void QTextOption::setTabs ( const QList< Tab > & tabStops)
Since
4.4 Sets the tab positions for the text layout to those specified by tabStops.
See also
tabStopDistance()

Definition at line 127 of file qtextoption.cpp.

References QTextOptionPrivate::tabStops.

◆ setTabStopDistance()

void QTextOption::setTabStopDistance ( qreal tabStopDistance)
inline
Since
5.10

Sets the default distance in device units between tab stops to the value specified by tabStopDistance.

See also
tabStopDistance(), setTabArray(), setTabs(), tabs()

Definition at line 113 of file qtextoption.h.

Referenced by QTextDocumentPrivate::QTextDocumentPrivate(), and QQuickTextEdit::setTabStopDistance().

+ Here is the caller graph for this function:

◆ setTextDirection()

void QTextOption::setTextDirection ( Qt::LayoutDirection direction)
inline

Sets the direction of the text layout defined by the option to the given direction.

See also
textDirection()

Definition at line 57 of file qtextoption.h.

References direction.

Referenced by QQuickTextInputPrivate::calculateImplicitWidthForText(), QTextDocumentLayoutPrivate::layoutBlock(), QTextLayout::setFlags(), QQC2::QCommonStylePrivate::toolButtonElideText(), and QQuickTextInputPrivate::updateLayout().

+ Here is the caller graph for this function:

◆ setUseDesignMetrics()

void QTextOption::setUseDesignMetrics ( bool enable)
inline

If enable is true then the layout will use design metrics; otherwise it will use the metrics of the paint device (which is the default behavior).

See also
useDesignMetrics()

Definition at line 91 of file qtextoption.h.

Referenced by QQuickTextMetrics::advanceWidth(), QQuickTextMetrics::boundingRect(), QQuickTextInputPrivate::init(), QQuickTextPrivate::setupTextLayout(), QQuickTextMetrics::tightBoundingRect(), and QVideoTextureHelper::SubtitleLayout::update().

+ Here is the caller graph for this function:

◆ setWrapMode()

void QTextOption::setWrapMode ( WrapMode wrap)
inline

Sets the option's text wrap mode to the given mode.

Definition at line 67 of file qtextoption.h.

References wrap().

Referenced by QTextDocumentPrivate::QTextDocumentPrivate(), QLabelPrivate::ensureTextLayouted(), QTextDocumentLayoutPrivate::layoutTable(), QQuickTextPrivate::setupTextLayout(), and QQC2::QCommonStylePrivate::toolButtonElideText().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tabArray()

QList< qreal > QTextOption::tabArray ( ) const

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

See also
setTabArray(), tabStopDistance()

Definition at line 139 of file qtextoption.cpp.

References QList< T >::constBegin(), QList< T >::constEnd(), iter, QList< T >::reserve(), QList< T >::size(), and QTextOptionPrivate::tabStops.

+ Here is the call graph for this function:

◆ tabs()

QList< QTextOption::Tab > QTextOption::tabs ( ) const
Since
4.4

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

See also
tabStopDistance(), setTabs(), setTabStopDistance()

Definition at line 155 of file qtextoption.cpp.

References QTextOptionPrivate::tabStops.

Referenced by setTabArray().

+ Here is the caller graph for this function:

◆ tabStopDistance()

qreal QTextOption::tabStopDistance ( ) const
inline
Since
5.10

Returns the distance in device units between tab stops.

See also
setTabStopDistance(), tabArray(), setTabs(), tabs()

Definition at line 83 of file qtextoption.h.

◆ textDirection()

Qt::LayoutDirection QTextOption::textDirection ( ) const
inline

Returns the direction of the text layout defined by the option.

See also
setTextDirection()

Definition at line 58 of file qtextoption.h.

References direction.

◆ useDesignMetrics()

bool QTextOption::useDesignMetrics ( ) const
inline

Returns true if the layout uses design rather than device metrics; otherwise returns false.

See also
setUseDesignMetrics()

Definition at line 92 of file qtextoption.h.

Referenced by QQuickTextPrivate::setupTextLayout().

+ Here is the caller graph for this function:

◆ wrapMode()

WrapMode QTextOption::wrapMode ( ) const
inline

Returns the text wrap mode defined by the option.

See also
setWrapMode()

Definition at line 68 of file qtextoption.h.

Referenced by QTextDocumentLayoutPrivate::layoutTable(), and QQuickTextPrivate::setupTextLayout().

+ Here is the caller graph for this function:

The documentation for this class was generated from the following files: