• PySide 模块
  • PySide.QtGui
  • 内容表

    上一话题

    QTextBlockGroup

    下一话题

    QAbstractTextDocumentLayout

    QTextList

    概要

    函数

    详细描述

    PySide.QtGui.QTextList class provides a decorated list of items in a PySide.QtGui.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.

    listFormat = QTextListFormat()
    if list:
        listFormat = list.format()
        listFormat.setIndent(listFormat.indent() + 1)
    listFormat.setStyle(QTextListFormat.ListDisc)
    cursor.insertList(listFormat)
    										

    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 PySide.QtGui.QTextList.count() . Each item can be obtained by its index in the list with the PySide.QtGui.QTextList.item() function. Similarly, the index of a given item can be found with PySide.QtGui.QTextList.itemNumber() . The text of each item can be found with the PySide.QtGui.QTextList.itemText() 函数。

    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 PySide.QtGui.QTextList.removeItem() 函数。 PySide.QtGui.QTextList.remove() deletes the specified item in the list.

    The list's format is set with PySide.QtGui.QTextList.setFormat() and read with PySide.QtGui.QTextList.format() . The format describes the decoration of the list itself, and not the individual items.

    class PySide.QtGui. QTextList ( doc )
    参数: doc PySide.QtGui.QTextDocument
    PySide.QtGui.QTextList. add ( block )
    参数: block PySide.QtGui.QTextBlock

    Makes the given block part of the list.

    PySide.QtGui.QTextList. count ( )
    返回类型: PySide.QtCore.int

    Returns the number of items in the list.

    PySide.QtGui.QTextList. item ( i )
    参数: i PySide.QtCore.int
    返回类型: PySide.QtGui.QTextBlock

    返回 i -th text block in the list.

    PySide.QtGui.QTextList. itemNumber ( arg__1 )
    参数: arg__1 PySide.QtGui.QTextBlock
    返回类型: PySide.QtCore.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.

    PySide.QtGui.QTextList. itemText ( arg__1 )
    参数: arg__1 PySide.QtGui.QTextBlock
    返回类型: unicode

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

    PySide.QtGui.QTextList. remove ( arg__1 )
    参数: arg__1 PySide.QtGui.QTextBlock

    移除给定 block from the list.

    PySide.QtGui.QTextList. removeItem ( i )
    参数: i PySide.QtCore.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 the PySide.QtGui.QTextDocument that owns it.

    PySide.QtGui.QTextList. setFormat ( format )
    参数: format PySide.QtGui.QTextListFormat

    Sets the list's format to format .

    另请参阅

    PySide.QtGui.QTextList.format()