QTextListFormat 類

The QTextListFormat class provides formatting information for lists in a QTextDocument . 更多...

頭: #include <QTextListFormat>
qmake: QT += gui
繼承: QTextFormat

注意: 此類的所有函數 可重入 .

公共類型

enum Style { ListDisc, ListCircle, ListSquare, ListDecimal, ..., ListUpperRoman }

公共函數

QTextListFormat ()
int indent () const
bool isValid () const
QString numberPrefix () const
QString numberSuffix () const
void setIndent (int indentation )
void setNumberPrefix (const QString & numberPrefix )
void setNumberSuffix (const QString & numberSuffix )
void setStyle (Style style )
Style style () const

詳細描述

The QTextListFormat class provides formatting information for lists in a QTextDocument .

A list is composed of one or more items, represented as text blocks. The list's format specifies the appearance of items in the list. In particular, it determines the indentation and the style of each item.

The indentation of the items is an integer value that causes each item to be offset from the left margin by a certain amount. This value is read with indent () 和設置采用 setIndent ().

The style used to decorate each item is set with setStyle () and can be read with the style () function. The style controls the type of bullet points and numbering scheme used for items in the list. Note that lists that use the decimal numbering scheme begin counting at 1 rather than 0.

Style properties can be set to further configure the appearance of list items; for example, the ListNumberPrefix and ListNumberSuffix properties can be used to customize the numbers used in an ordered list so that they appear as (1), (2), (3), etc.:

QTextListFormat listFormat;
listFormat.setStyle(QTextListFormat::ListDecimal);
listFormat.setNumberPrefix("(");
listFormat.setNumberSuffix(")");
cursor.insertList(listFormat);
					

另請參閱 QTextList .

成員類型文檔編製

enum QTextListFormat:: Style

此枚舉描述用於裝飾列錶項的符號:

常量 描述
QTextListFormat::ListDisc -1 a filled circle
QTextListFormat::ListCircle -2 空心圓
QTextListFormat::ListSquare -3 填充正方形
QTextListFormat::ListDecimal -4 decimal values in ascending order
QTextListFormat::ListLowerAlpha -5 lower case Latin characters in alphabetical order
QTextListFormat::ListUpperAlpha -6 upper case Latin characters in alphabetical order
QTextListFormat::ListLowerRoman -7 lower case roman numerals (supports up to 4999 items only)
QTextListFormat::ListUpperRoman -8 upper case roman numerals (supports up to 4999 items only)

成員函數文檔編製

QTextListFormat:: QTextListFormat ()

構造新列錶格式對象。

int QTextListFormat:: indent () const

Returns the list format's indentation. The indentation is multiplied by the QTextDocument::indentWidth property to get the effective indent in pixels.

另請參閱 setIndent ().

bool QTextListFormat:: isValid () const

返迴 true 若此列錶格式有效;否則返迴 false .

QString QTextListFormat:: numberPrefix () const

返迴列錶格式的數字前綴。

該函數在 Qt 4.8 引入。

另請參閱 setNumberPrefix ().

QString QTextListFormat:: numberSuffix () const

Returns the list format's number suffix.

該函數在 Qt 4.8 引入。

另請參閱 setNumberSuffix ().

void QTextListFormat:: setIndent ( int indentation )

Sets the list format's indentation . The indentation is multiplied by the QTextDocument::indentWidth property to get the effective indent in pixels.

另請參閱 indent ().

void QTextListFormat:: setNumberPrefix (const QString & numberPrefix )

Sets the list format's number prefix to the string specified by numberPrefix . This can be used with all sorted list types. It does not have any effect on unsorted list types.

The default prefix is an empty string.

該函數在 Qt 4.8 引入。

另請參閱 numberPrefix ().

void QTextListFormat:: setNumberSuffix (const QString & numberSuffix )

Sets the list format's number suffix to the string specified by numberSuffix . This can be used with all sorted list types. It does not have any effect on unsorted list types.

The default suffix is ".".

該函數在 Qt 4.8 引入。

另請參閱 numberSuffix ().

void QTextListFormat:: setStyle ( Style style )

Sets the list format's style .

另請參閱 style () 和 Style .

Style QTextListFormat:: style () const

Returns the list format's style.

另請參閱 setStyle () 和 Style .