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, ShowDefaultIgnorables, …, DisableEmojiParsing }
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 (since Qt 5.7) 0x10 Visualize the end of the document with a section sign.
QTextOption::ShowDefaultIgnorables (since Qt 6.9) 0x20 Render normally non-visual characters if supported by font.
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).
QTextOption::DisableEmojiParsing (since Qt 6.9) 0x40 By default, Qt will detect emoji sequences in input strings and prioritize using color fonts to display them. This extra step can be disabled by setting the DisableEmojiParsing flag if it is known in advance that it will not be needed.

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 .