QTextList¶
The
QTextList
class provides a decorated list of items in aQTextDocument
. More…
Synopsis¶
Functions¶
def
add
(block)def
count
()def
format
()def
item
(i)def
itemNumber
(arg__1)def
itemText
(arg__1)def
remove
(arg__1)def
removeItem
(i)def
setFormat
(format)
Detailed Description¶
A list contains a sequence of text blocks, each of which is marked with a bullet point or other symbol. Multiple levels of lists can be used, and the automatic numbering feature provides support for ordered numeric and alphabetical lists.
Lists are created by using a text cursor to insert an empty list at the current position or by moving existing text into a new list. The
insertList()
function inserts an empty block into the document at the cursor position, and makes it the first item in a list.QTextListFormat listFormat; if (list) { listFormat = list->format(); listFormat.setIndent(listFormat.indent() + 1); } listFormat.setStyle(QTextListFormat::ListDisc); cursor.insertList(listFormat);The
createList()
function takes the contents of the cursor’s current block and turns it into the first item of a new list.The cursor’s current list is found with
currentList()
.The number of items in a list is given by
count()
. Each item can be obtained by its index in the list with theitem()
function. Similarly, the index of a given item can be found withitemNumber()
. The text of each item can be found with theitemText()
function.Note that the items in the list may not be adjacent elements in the document. For example, the top-level items in a multi-level list will be separated by the items in lower levels of the list.
List items can be deleted by index with the
removeItem()
function.remove()
deletes the specified item in the list.The list’s format is set with
setFormat()
and read withformat()
. The format describes the decoration of the list itself, and not the individual items.See also
- class PySide2.QtGui.QTextList(doc)¶
- Parameters:
- PySide2.QtGui.QTextList.add(block)¶
- Parameters:
block –
PySide2.QtGui.QTextBlock
Makes the given
block
part of the list.See also
- PySide2.QtGui.QTextList.count()¶
- Return type:
int
Returns the number of items in the list.
- PySide2.QtGui.QTextList.format()¶
- Return type:
Returns the list’s format.
See also
- PySide2.QtGui.QTextList.item(i)¶
- Parameters:
i – int
- Return type:
Returns the
i
-th text block in the list.See also
- PySide2.QtGui.QTextList.itemNumber(arg__1)¶
- Parameters:
arg__1 –
PySide2.QtGui.QTextBlock
- Return type:
int
Returns the index of the list item that corresponds to the given
block
. Returns -1 if the block was not present in the list.
- PySide2.QtGui.QTextList.itemText(arg__1)¶
- Parameters:
arg__1 –
PySide2.QtGui.QTextBlock
- Return type:
str
Returns the text of the list item that corresponds to the given
block
.
- PySide2.QtGui.QTextList.remove(arg__1)¶
- Parameters:
arg__1 –
PySide2.QtGui.QTextBlock
Removes the given
block
from the list.See also
- PySide2.QtGui.QTextList.removeItem(i)¶
- Parameters:
i – int
Removes the item at item position
i
from the list. When the last item in the list is removed, the list is automatically deleted by theQTextDocument
that owns it.
- PySide2.QtGui.QTextList.setFormat(format)¶
- Parameters:
format –
PySide2.QtGui.QTextListFormat
Sets the list’s format to
format
.See also
© 2022 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.