Movatterモバイル変換


[0]ホーム

URL:


We bake cookies in your browser for a better experience. Using this site means that you consent.Read More

Menu

Qt Documentation

QTextList Class

TheQTextList class provides a decorated list of items in aQTextDocument.More...

Header:#include <QTextList>
Inherits:QTextBlockGroup

Note: All functions in this class arereentrant.

Public Functions

voidadd(const QTextBlock & block)
intcount() const
QTextListFormatformat() const
QTextBlockitem(int i) const
intitemNumber(const QTextBlock & block) const
QStringitemText(const QTextBlock & block) const
voidremove(const QTextBlock & block)
voidremoveItem(int i)
voidsetFormat(const QTextListFormat & format)

Additional Inherited Members

Detailed Description

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.

Member Function Documentation

void QTextList::add(constQTextBlock & block)

Makes the givenblock part of the list.

See alsoremove() andremoveItem().

int QTextList::count() const

Returns the number of items in the list.

QTextListFormat QTextList::format() const

Returns the list's format.

See alsosetFormat().

QTextBlock QTextList::item(int i) const

Returns thei-th text block in the list.

See alsocount() anditemText().

int QTextList::itemNumber(constQTextBlock & block) const

Returns the index of the list item that corresponds to the givenblock. Returns -1 if the block was not present in the list.

QString QTextList::itemText(constQTextBlock & block) const

Returns the text of the list item that corresponds to the givenblock.

void QTextList::remove(constQTextBlock & block)

Removes the givenblock from the list.

See alsoadd() andremoveItem().

void QTextList::removeItem(int i)

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.

See alsoadd() andremove().

void QTextList::setFormat(constQTextListFormat & format)

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.


[8]ページ先頭

©2009-2025 Movatter.jp