QTextListFormat 类提供格式化信息列表在 QTextDocument . 更多...
头: | #include <QTextListFormat> |
CMake: |
find_package(Qt6 REQUIRED COMPONENTS Gui)
target_link_libraries(mytarget PRIVATE Qt6::Gui) |
qmake: | QT += gui |
继承: | QTextFormat |
注意: 此类的所有函数 可重入 .
enum | Style { ListDisc, ListCircle, ListSquare, ListDecimal, ListLowerAlpha, …, 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 ) |
(从 6.6 起)
void
|
setStart (int start ) |
void | setStyle (QTextListFormat::Style style ) |
(从 6.6 起)
int
|
start () const |
QTextListFormat::Style | style () const |
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, unless it has been overridden via setStart ().
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 .
此枚举描述用于装饰列表项的符号:
常量 | 值 | 描述 |
---|---|---|
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) |
构造新列表格式对象。
Returns the list format's indentation. The indentation is multiplied by the QTextDocument::indentWidth property to get the effective indent in pixels.
另请参阅 setIndent ().
返回
true
若此列表格式有效;否则返回
false
.
返回列表格式的数字前缀。
另请参阅 setNumberPrefix ().
Returns the list format's number suffix.
另请参阅 setNumberSuffix ().
Sets the list format's indentation . The indentation is multiplied by the QTextDocument::indentWidth property to get the effective indent in pixels.
另请参阅 indent ().
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.
另请参阅 numberPrefix ().
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 ".".
另请参阅 numberSuffix ().
[since 6.6]
void
QTextListFormat::
setStart
(
int
start
)
Sets the list format's start 索引。
This allows you to start a list with an index other than 1. This can be used with all sorted list types: for example if the
style
() 是
QTextListFormat::ListLowerAlpha
and
start
() 是
4
, the first list item begins with "d". It does not have any effect on unsorted list types.
The default start is
1
.
该函数在 Qt 6.6 引入。
另请参阅 start ().
Sets the list format's style .
[since 6.6]
int
QTextListFormat::
start
() const
Returns the number to be shown by the first list item, if the style () 是 QTextListFormat::ListDecimal , or to offset other sorted list types.
该函数在 Qt 6.6 引入。
另请参阅 setStart ().
Returns the list format's style.