Home | All Classes | Main Classes | Annotated | Grouped Classes | Functions |

# QTextList Class Reference

The QTextList class provides a decorated list of items in a QTextDocument. More...

    #include <QTextList>

Inherits QTextBlockGroup.

- List of all members, including inherited members

### Writable Properties

- 1 writable property inherited from QObject

### Public Functions

- void add ( const QTextBlock & block )
- int count () const
- QTextListFormat format () const
- bool isEmpty () 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 )

- 3 public functions inherited from QTextObject
- 26 public functions inherited from QObject

### Public Slots

- 1 public slot inherited from QObject

### Signals

- 1 signal inherited from QObject

### Static Public Members

- 4 static public members inherited from QObject

### Protected Functions

- 4 protected functions inherited from QTextBlockGroup
- 1 protected function inherited from QTextObject
- 7 protected functions inherited from QObject

## Detailed Description

The QTextList class provides a decorated list of items in a QTextDocument.

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 QTextCursor::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.setStyle(QTextListFormat::ListDisc);
            listFormat.setIndent(listFormat.indent() + 1);
            cursor.insertList(listFormat);

The QTextCursor::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 QTextCursor::currentList().

The number of items in a list is given by count(). Each item can be obtained by its index in the list with the item() function. Similarly, the index of a given item can be found with itemNumber(). The text of each item can be found with the itemText() 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 with format(). The format describes the decoration of the list itself, and not the individual items.

See also QTextListFormat and QTextCursor.

## Member Function Documentation

### void QTextList::add ( const QTextBlock & block )

Makes the given block part of the list.

### int QTextList::count () const

Returns the number of items in the list.

See also isEmpty().

### QTextListFormat QTextList::format () const

Returns the list's format.

### bool QTextList::isEmpty () const

Returns true if the list has no items; otherwise returns false.

See also count().

### QTextBlock QTextList::item ( int i ) const

Returns the i-th text block in the list.

See also count() and itemText().

### int QTextList::itemNumber ( const QTextBlock & block ) const

Returns the index of the list item that corresponds to the given block.

### QString QTextList::itemText ( const QTextBlock & block ) const

Returns the text of the list item that corresponds to the given block.

### void QTextList::remove ( const QTextBlock & block )

Removes the given block from the list.

### void QTextList::removeItem ( int i )

Removes the item at item position i from the list.

### void QTextList::setFormat ( const QTextListFormat & format )

Sets the list's format to format.