QTextOption 类

QTextOption 类提供一般富文本特性的描述。 更多...

头: #include <QTextOption>
CMake: find_package(Qt6 REQUIRED COMPONENTS Gui)
target_link_libraries(mytarget PRIVATE Qt6::Gui)
qmake: QT += gui

注意: 此类的所有函数 可重入 .

公共类型

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

公共函数

QTextOption ()
QTextOption (Qt::Alignment alignment )
QTextOption (const QTextOption & other )
~QTextOption ()
Qt::Alignment alignment () const
QTextOption::Flags flags () const
void setAlignment (Qt::Alignment alignment )
void setFlags (QTextOption::Flags flags )
void setTabArray (const QList<qreal> & tabStops )
void setTabStopDistance (qreal tabStopDistance )
void setTabs (const QList<QTextOption::Tab> & tabStops )
void setTextDirection (Qt::LayoutDirection direction )
void setUseDesignMetrics (bool enable )
void setWrapMode (QTextOption::WrapMode mode )
QList<qreal> tabArray () const
qreal tabStopDistance () const
QList<QTextOption::Tab> tabs () const
Qt::LayoutDirection textDirection () const
bool useDesignMetrics () const
QTextOption::WrapMode wrapMode () const
QTextOption & operator= (const QTextOption & other )

详细描述

QTextOption 用于把常见富文本特性封装在单对象中。它包含文本对齐、布局方向、自动换行及其它与文本渲染和布局关联的标准特性的有关信息。

另请参阅 QTextEdit , QTextDocument ,和 QTextCursor .

成员类型文档编制

enum QTextOption:: Flag
flags QTextOption:: Flags

常量 描述
QTextOption::IncludeTrailingSpaces 0x80000000 当此选项有设置时, QTextLine::naturalTextWidth () and naturalTextRect() will return a value that includes the width of trailing spaces in the text; otherwise this width is excluded.
QTextOption::ShowTabsAndSpaces 0x1 Visualize spaces with little dots, and tabs with little arrows. Non-breaking spaces are shown differently to breaking spaces.
QTextOption::ShowLineAndParagraphSeparators 0x2 Visualize line and paragraph separators with appropriate symbol characters.
QTextOption::ShowDocumentTerminator 0x10 Visualize the end of the document with a section sign. This enum value was added in Qt 5.7.
QTextOption::AddSpaceForLineAndParagraphSeparators 0x4 While determining the line-break positions take into account the space added for drawing a separator character.
QTextOption::SuppressColors 0x8 Suppress all color changes in the character formats (except the main selection).

Flags 类型是 typedef 对于 QFlags <Flag>。它存储 Flag 值的 OR 组合。

enum QTextOption:: TabType

此枚举包含不同类型的制表符

常量 描述
QTextOption::LeftTab 0 左 Tab
QTextOption::RightTab 1 右 Tab
QTextOption::CenterTab 2 居中 Tab
QTextOption::DelimiterTab 3 停在某个定界符处的 Tab

enum QTextOption:: WrapMode

此枚举描述文本如何在文档中换行。

常量 描述
QTextOption::NoWrap 0 文本根本不换行。
QTextOption::WordWrap 1 文本在单词边界处换行。
QTextOption::ManualWrap 2 如同 QTextOption::NoWrap
QTextOption::WrapAnywhere 3 文本可以在行的任何位置处换行,即使出现在单词中间。
QTextOption::WrapAtWordBoundaryOrAnywhere 4 若可能,在单词边界处换行;否则,换行将出现在行的适当位置处,甚至在单词中间。

成员函数文档编制

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 。设计指标所用标志被设为 false。

QTextOption:: QTextOption ( Qt::Alignment alignment )

构造文本选项采用给定 alignment 为文本。单词换行特性被设为 QTextOption::WordWrap 。设计指标所用标志被设为 false。

QTextOption:: QTextOption (const QTextOption & other )

构造副本为 other 文本选项。

[noexcept] QTextOption:: ~QTextOption ()

销毁文本选项。

Qt::Alignment QTextOption:: alignment () const

返回由选项定义的文本对齐方式。

另请参阅 setAlignment ().

QTextOption::Flags QTextOption:: flags () const

返回与选项关联的标志。

另请参阅 setFlags ().

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

将选项的文本对齐方式设为指定 alignment .

另请参阅 alignment ().

void QTextOption:: setFlags ( QTextOption::Flags flags )

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

另请参阅 flags ().

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

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

另请参阅 tabArray (), setTabStopDistance (),和 setTabs ().

void QTextOption:: setTabStopDistance ( qreal tabStopDistance )

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

另请参阅 tabStopDistance (), setTabArray (), setTabs (),和 tabs ().

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

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

另请参阅 tabs () 和 tabStopDistance ().

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

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

另请参阅 textDirection ().

void QTextOption:: setUseDesignMetrics ( bool enable )

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

另请参阅 useDesignMetrics ().

void QTextOption:: setWrapMode ( QTextOption::WrapMode mode )

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

另请参阅 wrapMode ().

QList < qreal > QTextOption:: tabArray () const

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

另请参阅 setTabArray () 和 tabStopDistance ().

qreal QTextOption:: tabStopDistance () const

Returns the distance in device units between tab stops.

另请参阅 setTabStopDistance (), tabArray (), setTabs (),和 tabs ().

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

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

另请参阅 tabStopDistance (), setTabs (),和 setTabStopDistance ().

Qt::LayoutDirection QTextOption:: textDirection () const

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

另请参阅 setTextDirection ().

bool QTextOption:: useDesignMetrics () const

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

另请参阅 setUseDesignMetrics ().

QTextOption::WrapMode QTextOption:: wrapMode () const

返回由选项定义的文本换行模式。

另请参阅 setWrapMode ().

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

返回 true 如果文本选项如同 other 文本选项;否则返回 false .