
We bake cookies in your browser for a better experience. Using this site means that you consent.Read More
TheQTextList class provides a decorated list of items in aQTextDocument.More...
| Header: | #include <QTextList> |
| Inherits: | QTextBlockGroup |
Note: All functions in this class arereentrant.
| void | add(const QTextBlock & block) |
| int | count() const |
| QTextListFormat | format() const |
| QTextBlock | item(int i) const |
| int | itemNumber(const QTextBlock & block) const |
| QString | itemText(const QTextBlock & block) const |
| void | remove(const QTextBlock & block) |
| void | removeItem(int i) |
| void | setFormat(const QTextListFormat & format) |
TheQTextList class provides a decorated list of items in aQTextDocument.
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. TheQTextCursor::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);
TheQTextCursor::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 withQTextCursor::currentList().
The number of items in a list is given bycount(). 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 theremoveItem() function.remove() deletes the specified item in the list.
The list's format is set withsetFormat() and read withformat(). The format describes the decoration of the list itself, and not the individual items.
See alsoQTextBlock,QTextListFormat, andQTextCursor.
Makes the givenblock part of the list.
See alsoremove() andremoveItem().
Returns the number of items in the list.
Returns the list's format.
See alsosetFormat().
Returns thei-th text block in the list.
See alsocount() anditemText().
Returns the index of the list item that corresponds to the givenblock. Returns -1 if the block was not present in the list.
Returns the text of the list item that corresponds to the givenblock.
Removes the givenblock from the list.
See alsoadd() andremoveItem().
Removes the item at item positioni from the list. When the last item in the list is removed, the list is automatically deleted by theQTextDocument that owns it.
Sets the list's format toformat.
See alsoformat().
© 2016 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 theGNU 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.