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

    上一话题

    QStandardItem

    下一话题

    QItemEditorFactory

    QListWidgetItem

    概要

    函数

    虚函数

    详细描述

    PySide.QtGui.QListWidgetItem class provides an item for use with the PySide.QtGui.QListWidget 项视图类。

    A PySide.QtGui.QListWidgetItem represents a single item in a PySide.QtGui.QListWidget . Each item can hold several pieces of information, and will display them appropriately.

    The item view convenience classes use a classic item-based interface rather than a pure model/view approach. For a more flexible list view widget, consider using the PySide.QtGui.QListView 类采用标准模型。

    List items can be inserted automatically into a list, when they are constructed, by specifying the list widget:

    QListWidgetItem(tr("Hazel"), listWidget)
    										

    Alternatively, list items can also be created without a parent widget, and later inserted into a list using QListWidget.insertItem() .

    List items are typically used to display PySide.QtGui.QListWidgetItem.text() PySide.QtGui.QListWidgetItem.icon() . These are set with the PySide.QtGui.QListWidgetItem.setText() and PySide.QtGui.QListWidgetItem.setIcon() functions. The appearance of the text can be customized with PySide.QtGui.QListWidgetItem.setFont() , PySide.QtGui.QListWidgetItem.setForeground() ,和 PySide.QtGui.QListWidgetItem.setBackground() . Text in list items can be aligned using the PySide.QtGui.QListWidgetItem.setTextAlignment() function. Tooltips, status tips and “What's This?” help can be added to list items with PySide.QtGui.QListWidgetItem.setToolTip() , PySide.QtGui.QListWidgetItem.setStatusTip() ,和 PySide.QtGui.QListWidgetItem.setWhatsThis() .

    By default, items are enabled, selectable, checkable, and can be the source of drag and drop operations.

    Each item's flags can be changed by calling PySide.QtGui.QListWidgetItem.setFlags() with the appropriate value (see Qt.ItemFlags ). Checkable items can be checked, unchecked and partially checked with the PySide.QtGui.QListWidgetItem.setCheckState() function. The corresponding PySide.QtGui.QListWidgetItem.checkState() function indicates the item's current check state.

    PySide.QtGui.QListWidgetItem.isHidden() function can be used to determine whether the item is hidden. To hide an item, use PySide.QtGui.QListWidgetItem.setHidden() .

    子类化

    当子类化 PySide.QtGui.QListWidgetItem to provide custom items, it is possible to define new types for them enabling them to be distinguished from standard items. For subclasses that require this feature, ensure that you call the base class constructor with a new type value equal to or greater than UserType , within your 构造函数。

    class PySide.QtGui. QListWidgetItem ( [ view=None [ , type=Type ] ] )
    class PySide.QtGui. QListWidgetItem ( icon , text [ , view=None [ , type=Type ] ] )
    class PySide.QtGui. QListWidgetItem ( other )
    class PySide.QtGui. QListWidgetItem ( text [ , view=None [ , type=Type ] ] )
    参数:

    Constructs an empty list widget item of the specified type 采用给定 parent 。若 parent is not specified, the item will need to be inserted into a list widget with QListWidget.insertItem() .

    This constructor inserts the item into the model of the parent that is passed to the constructor. If the model is sorted then the behavior of the insert is undetermined since the model will call the '<' operator method on the item which, at this point, is not yet constructed. To avoid the undetermined behavior, we recommend not to specify the parent and use QListWidget.insertItem() 代替。

    Constructs an empty list widget item of the specified type 采用给定 icon , text and parent . If the parent is not specified, the item will need to be inserted into a list widget with QListWidget.insertItem() .

    This constructor inserts the item into the model of the parent that is passed to the constructor. If the model is sorted then the behavior of the insert is undetermined since the model will call the '<' operator method on the item which, at this point, is not yet constructed. To avoid the undetermined behavior, we recommend not to specify the parent and use QListWidget.insertItem() 代替。

    构造副本为 other 。注意 PySide.QtGui.QListWidgetItem.type() and PySide.QtGui.QListWidgetItem.listWidget() are not copied.

    此函数是有用的,当重实现 PySide.QtGui.QListWidgetItem.clone() .

    Constructs an empty list widget item of the specified type 采用给定 text and parent . If the parent is not specified, the item will need to be inserted into a list widget with QListWidget.insertItem() .

    This constructor inserts the item into the model of the parent that is passed to the constructor. If the model is sorted then the behavior of the insert is undetermined since the model will call the '<' operator method on the item which, at this point, is not yet constructed. To avoid the undetermined behavior, we recommend not to specify the parent and use QListWidget.insertItem() 代替。

    PySide.QtGui.QListWidgetItem. ItemType

    This enum describes the types that are used to describe list widget items.

    常量 描述
    QListWidgetItem.Type The default type for list widget items.
    QListWidgetItem.UserType The minimum value for custom types. Values below UserType are reserved by Qt.

    可以定义新用户类型在 PySide.QtGui.QListWidgetItem subclasses to ensure that custom items are treated specially.

    PySide.QtGui.QListWidgetItem. background ( )
    返回类型: PySide.QtGui.QBrush

    Returns the brush used to display the list item's background.

    PySide.QtGui.QListWidgetItem. checkState ( )
    返回类型: PySide.QtCore.Qt.CheckState

    Returns the checked state of the list item (see Qt.CheckState ).

    PySide.QtGui.QListWidgetItem. clone ( )
    返回类型: PySide.QtGui.QListWidgetItem

    Creates an exact copy of the item.

    PySide.QtGui.QListWidgetItem. data ( role )
    参数: role PySide.QtCore.int
    返回类型: object

    Returns the item's data for a given role . Reimplement this function if you need extra roles or special behavior for certain roles.

    另请参阅

    Qt.ItemDataRole PySide.QtGui.QListWidgetItem.setData()

    PySide.QtGui.QListWidgetItem. flags ( )
    返回类型: PySide.QtCore.Qt.ItemFlags

    Returns the item flags for this item (see Qt.ItemFlags ).

    PySide.QtGui.QListWidgetItem. font ( )
    返回类型: PySide.QtGui.QFont

    Returns the font used to display this list item's text.

    PySide.QtGui.QListWidgetItem. foreground ( )
    返回类型: PySide.QtGui.QBrush

    Returns the brush used to display the list item's foreground (e.g. text).

    PySide.QtGui.QListWidgetItem. icon ( )
    返回类型: PySide.QtGui.QIcon

    Returns the list item's icon.

    PySide.QtGui.QListWidgetItem. isHidden ( )
    返回类型: PySide.QtCore.bool

    Returns true if the item is hidden; otherwise returns false.

    PySide.QtGui.QListWidgetItem. isSelected ( )
    返回类型: PySide.QtCore.bool

    Returns true if the item is selected; otherwise returns false.

    PySide.QtGui.QListWidgetItem. listWidget ( )
    返回类型: PySide.QtGui.QListWidget

    Returns the list widget containing the item.

    PySide.QtGui.QListWidgetItem. __lt__ ( other )
    参数: other PySide.QtGui.QListWidgetItem
    返回类型: PySide.QtCore.bool

    Returns true if this item's text is less then other item's text; otherwise returns false.

    PySide.QtGui.QListWidgetItem. read ( in )
    参数: in PySide.QtCore.QDataStream

    读取项从流 in .

    PySide.QtGui.QListWidgetItem. setBackground ( brush )
    参数: brush PySide.QtGui.QBrush

    Sets the background brush of the list item to the given brush .

    PySide.QtGui.QListWidgetItem. setCheckState ( state )
    参数: state PySide.QtCore.Qt.CheckState
    PySide.QtGui.QListWidgetItem. setData ( role , value )
    参数:
    • role PySide.QtCore.int
    • value – object

    Sets the data for a given role 到给定 value . Reimplement this function if you need extra roles or special behavior for certain roles.

    另请参阅

    Qt.ItemDataRole PySide.QtGui.QListWidgetItem.data()

    PySide.QtGui.QListWidgetItem. setFlags ( flags )
    参数: flags PySide.QtCore.Qt.ItemFlags
    PySide.QtGui.QListWidgetItem. setFont ( font )
    参数: font PySide.QtGui.QFont

    Sets the font used when painting the item to the given font .

    PySide.QtGui.QListWidgetItem. setForeground ( brush )
    参数: brush PySide.QtGui.QBrush

    Sets the foreground brush of the list item to the given brush .

    PySide.QtGui.QListWidgetItem. setHidden ( hide )
    参数: hide PySide.QtCore.bool

    隐藏项若 hide is true; otherwise shows the item.

    PySide.QtGui.QListWidgetItem. setIcon ( icon )
    参数: icon PySide.QtGui.QIcon

    Sets the icon for the list item to the given icon .

    PySide.QtGui.QListWidgetItem. setSelected ( select )
    参数: select PySide.QtCore.bool

    将项的选定状态设为 select .

    PySide.QtGui.QListWidgetItem. setSizeHint ( size )
    参数: size PySide.QtCore.QSize

    Sets the size hint for the list item to be size . If no size hint is set, the item delegate will compute the size hint based on the item data.

    PySide.QtGui.QListWidgetItem. setStatusTip ( statusTip )
    参数: statusTip – unicode

    Sets the status tip for the list item to the text specified by statusTip . PySide.QtGui.QListWidget mouseTracking needs to be enabled for this feature to work.

    PySide.QtGui.QListWidgetItem. setText ( text )
    参数: text – unicode

    把列表 Widget 项的文本,设为给定 text .

    PySide.QtGui.QListWidgetItem. setTextAlignment ( alignment )
    参数: alignment PySide.QtCore.int

    把列表项的文本对齐方式,设为 alignment .

    PySide.QtGui.QListWidgetItem. setToolTip ( toolTip )
    参数: toolTip – unicode

    Sets the tooltip for the list item to the text specified by toolTip .

    PySide.QtGui.QListWidgetItem. setWhatsThis ( whatsThis )
    参数: whatsThis – unicode

    Sets the “What's This?” help for the list item to the text specified by whatsThis .

    PySide.QtGui.QListWidgetItem. sizeHint ( )
    返回类型: PySide.QtCore.QSize

    返回列表项的大小提示设置。

    PySide.QtGui.QListWidgetItem. statusTip ( )
    返回类型: unicode

    返回列表项的状态提示。

    PySide.QtGui.QListWidgetItem. text ( )
    返回类型: unicode

    返回列表项的文本。

    PySide.QtGui.QListWidgetItem. textAlignment ( )
    返回类型: PySide.QtCore.int

    返回列表项的文本对齐方式。

    PySide.QtGui.QListWidgetItem. toolTip ( )
    返回类型: unicode

    返回列表项的工具提示。

    PySide.QtGui.QListWidgetItem. type ( )
    返回类型: PySide.QtCore.int

    返回类型被传递给 PySide.QtGui.QListWidgetItem 构造函数。

    PySide.QtGui.QListWidgetItem. whatsThis ( )
    返回类型: unicode

    Returns the list item's “What's This?” help text.

    PySide.QtGui.QListWidgetItem. write ( out )
    参数: out PySide.QtCore.QDataStream

    把项写入流 out .