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

    上一话题

    QTableWidgetSelectionRange

    下一话题

    QListWidgetItem

    QStandardItem

    概要

    函数

    虚函数

    详细描述

    PySide.QtGui.QStandardItem class provides an item for use with the PySide.QtGui.QStandardItemModel 类。

    Items usually contain text, icons, or checkboxes.

    Each item can have its own background brush which is set with the PySide.QtGui.QStandardItem.setBackground() function. The current background brush can be found with PySide.QtGui.QStandardItem.background() . The text label for each item can be rendered with its own font and brush. These are specified with the PySide.QtGui.QStandardItem.setFont() and PySide.QtGui.QStandardItem.setForeground() functions, and read with PySide.QtGui.QStandardItem.font() and PySide.QtGui.QStandardItem.foreground() .

    By default, items are enabled, editable, selectable, checkable, and can be used both as the source of a drag and drop operation and as a drop target. Each item's flags can be changed by calling PySide.QtGui.QStandardItem.setFlags() . Checkable items can be checked and unchecked with the PySide.QtGui.QStandardItem.setCheckState() function. The corresponding PySide.QtGui.QStandardItem.checkState() function indicates whether the item is currently checked.

    You can store application-specific data in an item by calling PySide.QtGui.QStandardItem.setData() .

    Each item can have a two-dimensional table of child items. This makes it possible to build hierarchies of items. The typical hierarchy is the tree, in which case the child table is a table with a single column (a list).

    The dimensions of the child table can be set with PySide.QtGui.QStandardItem.setRowCount() and PySide.QtGui.QStandardItem.setColumnCount() . Items can be positioned in the child table with PySide.QtGui.QStandardItem.setChild() . Get a pointer to a child item with PySide.QtGui.QStandardItem.child() . New rows and columns of children can also be inserted with PySide.QtGui.QStandardItem.insertRow() and PySide.QtGui.QStandardItem.insertColumn() , or appended with PySide.QtGui.QStandardItem.appendRow() and PySide.QtGui.QStandardItem.appendColumn() . When using the append and insert functions, the dimensions of the child table will grow as needed.

    An existing row of children can be removed with PySide.QtGui.QStandardItem.removeRow() or PySide.QtGui.QStandardItem.takeRow() ; correspondingly, a column can be removed with PySide.QtGui.QStandardItem.removeColumn() or PySide.QtGui.QStandardItem.takeColumn() .

    An item's children can be sorted by calling PySide.QtGui.QStandardItem.sortChildren() .

    子类化

    当子类化 PySide.QtGui.QStandardItem to provide custom items, it is possible to define new types for them so that they can be distinguished from the base class. The PySide.QtGui.QStandardItem.type() function should be reimplemented to return a new type value equal to or greater than UserType .

    Reimplement PySide.QtGui.QStandardItem.data() and PySide.QtGui.QStandardItem.setData() if you want to perform custom handling of data queries and/or control how an item's data is represented.

    Reimplement PySide.QtGui.QStandardItem.clone() if you want PySide.QtGui.QStandardItemModel to be able to create instances of your custom item class on demand (see QStandardItemModel.setItemPrototype() ).

    Reimplement PySide.QtGui.QStandardItem.read() and PySide.QtGui.QStandardItem.write() if you want to control how items are represented in their serialized form.

    Reimplement PySide.QtGui.QStandardItem.operator<() if you want to control the semantics of item comparison. PySide.QtGui.QStandardItem.operator<() determines the sorted order when sorting items with PySide.QtGui.QStandardItem.sortChildren() or with QStandardItemModel.sort() .

    另请参阅

    PySide.QtGui.QStandardItemModel 项视图方便类 模型/视图编程

    class PySide.QtGui. QStandardItem
    class PySide.QtGui. QStandardItem ( icon , text )
    class PySide.QtGui. QStandardItem ( other )
    class PySide.QtGui. QStandardItem ( text )
    class PySide.QtGui. QStandardItem ( rows [ , columns=1 ] )
    参数:

    Constructs an item.

    Constructs an item with the given icon and text .

    构造副本为 other 。注意 PySide.QtGui.QStandardItem.model() is not copied.

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

    Constructs an item with the given text .

    Constructs an item with rows rows and columns columns of child items.

    PySide.QtGui.QStandardItem. ItemType

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

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

    可以定义新用户类型在 PySide.QtGui.QStandardItem 子类以确保自定义项得到特殊处理;例如,当排序项时。

    PySide.QtGui.QStandardItem. accessibleDescription ( )
    返回类型: unicode

    Returns the item's accessible description.

    The accessible description is used by assistive technologies (i.e. for users who cannot use conventional means of interaction).

    PySide.QtGui.QStandardItem. accessibleText ( )
    返回类型: unicode

    Returns the item's accessible text.

    The accessible text is used by assistive technologies (i.e. for users who cannot use conventional means of interaction).

    PySide.QtGui.QStandardItem. appendColumn ( items )
    参数: items
    PySide.QtGui.QStandardItem. appendRow ( item )
    参数: item PySide.QtGui.QStandardItem

    这是重载函数。

    Appends a row containing item .

    When building a list or a tree that has only one column, this function provides a convenient way to append a single new item.

    PySide.QtGui.QStandardItem. appendRow ( items )
    参数: items
    PySide.QtGui.QStandardItem. appendRows ( items )
    参数: items
    PySide.QtGui.QStandardItem. background ( )
    返回类型: PySide.QtGui.QBrush

    Returns the brush used to render the item's background.

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

    Returns the checked state of the item.

    PySide.QtGui.QStandardItem. child ( row [ , column=0 ] )
    参数:
    • row PySide.QtCore.int
    • column PySide.QtCore.int
    返回类型:

    PySide.QtGui.QStandardItem

    Returns the child item at ( row , column ) if one has been set; otherwise returns 0.

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

    Returns a copy of this item. The item's children are not copied.

    当子类化 PySide.QtGui.QStandardItem , you can reimplement this function to provide PySide.QtGui.QStandardItemModel with a factory that it can use to create new items on demand.

    另请参阅

    QStandardItemModel.setItemPrototype() PySide.QtGui.QStandardItem.operator=()

    PySide.QtGui.QStandardItem. column ( )
    返回类型: PySide.QtCore.int

    Returns the column where the item is located in its parent's child table, or -1 if the item has no parent.

    PySide.QtGui.QStandardItem. columnCount ( )
    返回类型: PySide.QtCore.int

    Returns the number of child item columns that the item has.

    PySide.QtGui.QStandardItem. data ( [ role=Qt.UserRole + 1 ] )
    参数: role PySide.QtCore.int
    返回类型: object

    Returns the item's data for the given role , or an invalid PySide.QtCore.QVariant if there is no data for the role.

    注意

    默认实现视 Qt.EditRole and Qt.DisplayRole 为引用相同数据。

    PySide.QtGui.QStandardItem. emitDataChanged ( )

    促使关联此项的模型发射 PySide.QtCore.QAbstractItemModel.dataChanged() () 信号对于此项。

    通常只需调用此函数若有子类化 PySide.QtGui.QStandardItem 和重实现 PySide.QtGui.QStandardItem.data() and/or PySide.QtGui.QStandardItem.setData() .

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

    Returns the item flags for the item.

    The item flags determine how the user can interact with the item.

    By default, items are enabled, editable, selectable, checkable, and can be used both as the source of a drag and drop operation and as a drop target.

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

    Returns the font used to render the item's text.

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

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

    PySide.QtGui.QStandardItem. hasChildren ( )
    返回类型: PySide.QtCore.bool

    Returns true if this item has any children; otherwise returns false.

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

    Returns the item's icon.

    PySide.QtGui.QStandardItem. index ( )
    返回类型: PySide.QtCore.QModelIndex

    返回 PySide.QtCore.QModelIndex associated with this item.

    When you need to invoke item functionality in a PySide.QtCore.QModelIndex -based API (e.g. PySide.QtGui.QAbstractItemView ), you can call this function to obtain an index that corresponds to the item's location in the model.

    If the item is not associated with a model, an invalid PySide.QtCore.QModelIndex 被返回。

    PySide.QtGui.QStandardItem. insertColumn ( column , items )
    参数:
    • column PySide.QtCore.int
    • items
    PySide.QtGui.QStandardItem. insertColumns ( column , count )
    参数:
    • column PySide.QtCore.int
    • count PySide.QtCore.int

    插入 count columns of child items at column column .

    PySide.QtGui.QStandardItem. insertRow ( row , items )
    参数:
    • row PySide.QtCore.int
    • items
    PySide.QtGui.QStandardItem. insertRow ( row , item )
    参数:

    这是重载函数。

    Inserts a row at row containing item .

    When building a list or a tree that has only one column, this function provides a convenient way to insert a single new item.

    PySide.QtGui.QStandardItem. insertRows ( row , items )
    参数:
    • row PySide.QtCore.int
    • items
    PySide.QtGui.QStandardItem. insertRows ( row , count )
    参数:
    • row PySide.QtCore.int
    • count PySide.QtCore.int

    插入 count rows of child items at row row .

    PySide.QtGui.QStandardItem. isCheckable ( )
    返回类型: PySide.QtCore.bool

    Returns whether the item is user-checkable.

    默认值为 false。

    PySide.QtGui.QStandardItem. isDragEnabled ( )
    返回类型: PySide.QtCore.bool

    Returns whether the item is drag enabled. An item that is drag enabled can be dragged by the user.

    默认值为 true。

    Note that item dragging must be enabled in the view for dragging to work; see QAbstractItemView.dragEnabled .

    PySide.QtGui.QStandardItem. isDropEnabled ( )
    返回类型: PySide.QtCore.bool

    Returns whether the item is drop enabled. When an item is drop enabled, it can be used as a drop target.

    默认值为 true。

    PySide.QtGui.QStandardItem. isEditable ( )
    返回类型: PySide.QtCore.bool

    Returns whether the item can be edited by the user.

    When an item is editable (and enabled), the user can edit the item by invoking one of the view's edit triggers; see QAbstractItemView.editTriggers .

    默认值为 true。

    PySide.QtGui.QStandardItem. isEnabled ( )
    返回类型: PySide.QtCore.bool

    Returns whether the item is enabled.

    When an item is enabled, the user can interact with it. The possible types of interaction are specified by the other item flags, such as PySide.QtGui.QStandardItem.isEditable() and PySide.QtGui.QStandardItem.isSelectable() .

    默认值为 true。

    PySide.QtGui.QStandardItem. isSelectable ( )
    返回类型: PySide.QtCore.bool

    Returns whether the item is selectable by the user.

    默认值为 true。

    PySide.QtGui.QStandardItem. isTristate ( )
    返回类型: PySide.QtCore.bool

    Returns whether the item is tristate; that is, if it's checkable with three separate states.

    默认值为 false。

    PySide.QtGui.QStandardItem. model ( )
    返回类型: PySide.QtGui.QStandardItemModel

    返回 PySide.QtGui.QStandardItemModel that this item belongs to.

    If the item is not a child of another item that belongs to the model, this function returns 0.

    PySide.QtGui.QStandardItem. parent ( )
    返回类型: PySide.QtGui.QStandardItem

    Returns the item's parent item, or 0 if the item has no parent.

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

    读取项从流 in . Only the data and flags of the item are read, not the child items.

    PySide.QtGui.QStandardItem. removeColumn ( column )
    参数: column PySide.QtCore.int

    移除给定 column . The items that were in the column are deleted.

    PySide.QtGui.QStandardItem. removeColumns ( column , count )
    参数:
    • column PySide.QtCore.int
    • count PySide.QtCore.int

    移除 count columns at column column . The items that were in those columns are deleted.

    PySide.QtGui.QStandardItem. removeRow ( row )
    参数: row PySide.QtCore.int

    移除给定 row . The items that were in the row are deleted.

    PySide.QtGui.QStandardItem. removeRows ( row , count )
    参数:
    • row PySide.QtCore.int
    • count PySide.QtCore.int

    移除 count rows at row row . The items that were in those rows are deleted.

    PySide.QtGui.QStandardItem. row ( )
    返回类型: PySide.QtCore.int

    Returns the row where the item is located in its parent's child table, or -1 if the item has no parent.

    PySide.QtGui.QStandardItem. rowCount ( )
    返回类型: PySide.QtCore.int

    Returns the number of child item rows that the item has.

    PySide.QtGui.QStandardItem. setAccessibleDescription ( accessibleDescription )
    参数: accessibleDescription – unicode

    Sets the item's accessible description to the string specified by accessibleDescription .

    The accessible description is used by assistive technologies (i.e. for users who cannot use conventional means of interaction).

    PySide.QtGui.QStandardItem. setAccessibleText ( accessibleText )
    参数: accessibleText – unicode

    Sets the item's accessible text to the string specified by accessibleText .

    The accessible text is used by assistive technologies (i.e. for users who cannot use conventional means of interaction).

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

    Sets the item's background brush to the specified brush .

    PySide.QtGui.QStandardItem. setCheckState ( checkState )
    参数: checkState PySide.QtCore.Qt.CheckState
    PySide.QtGui.QStandardItem. setCheckable ( checkable )
    参数: checkable PySide.QtCore.bool

    Sets whether the item is user-checkable. If checkable is true, the item can be checked by the user; otherwise, the user cannot check the item.

    The item delegate will render a checkable item with a check box next to the item's text.

    PySide.QtGui.QStandardItem. setChild ( row , column , item )
    参数:

    Sets the child item at ( row , column ) 到 item . This item (the parent item) takes ownership of item . If necessary, the row count and column count are increased to fit the item.

    PySide.QtGui.QStandardItem. setChild ( row , item )
    参数:

    这是重载函数。

    Sets the child at row to item .

    PySide.QtGui.QStandardItem. setColumnCount ( columns )
    参数: columns PySide.QtCore.int

    Sets the number of child item columns to columns . If this is less than PySide.QtGui.QStandardItem.columnCount() , the data in the unwanted columns is discarded.

    PySide.QtGui.QStandardItem. setData ( value [ , role=Qt.UserRole + 1 ] )
    参数:
    • value – object
    • role PySide.QtCore.int

    Sets the item's data for the given role 到指定 value .

    If you subclass PySide.QtGui.QStandardItem and reimplement this function, your reimplementation should call PySide.QtGui.QStandardItem.emitDataChanged() if you do not call the base implementation of PySide.QtGui.QStandardItem.setData() . This will ensure that e.g. views using the model are notified of the changes.

    注意

    默认实现视 Qt.EditRole and Qt.DisplayRole 为引用相同数据。

    PySide.QtGui.QStandardItem. setDragEnabled ( dragEnabled )
    参数: dragEnabled PySide.QtCore.bool

    Sets whether the item is drag enabled. If dragEnabled is true, the item can be dragged by the user; otherwise, the user cannot drag the item.

    Note that you also need to ensure that item dragging is enabled in the view; see QAbstractItemView.dragEnabled .

    PySide.QtGui.QStandardItem. setDropEnabled ( dropEnabled )
    参数: dropEnabled PySide.QtCore.bool

    Sets whether the item is drop enabled. If dropEnabled is true, the item can be used as a drop target; otherwise, it cannot.

    Note that you also need to ensure that drops are enabled in the view; see QWidget.acceptDrops() ; and that the model supports the desired drop actions; see QAbstractItemModel.supportedDropActions() .

    PySide.QtGui.QStandardItem. setEditable ( editable )
    参数: editable PySide.QtCore.bool

    Sets whether the item is editable. If editable is true, the item can be edited by the user; otherwise, the user cannot edit the item.

    How the user can edit items in a view is determined by the view's edit triggers; see QAbstractItemView.editTriggers .

    PySide.QtGui.QStandardItem. setEnabled ( enabled )
    参数: enabled PySide.QtCore.bool

    Sets whether the item is enabled. If enabled is true, the item is enabled, meaning that the user can interact with the item; if enabled is false, the user cannot interact with the item.

    This flag takes precedence over the other item flags; e.g. if an item is not enabled, it cannot be selected by the user, even if the Qt.ItemIsSelectable flag has been set.

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

    Sets the font used to display the item's text to the given font .

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

    Sets the brush used to display the item's foreground (e.g. text) to the given brush .

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

    Sets the item's icon to the icon 指定。

    PySide.QtGui.QStandardItem. setRowCount ( rows )
    参数: rows PySide.QtCore.int

    Sets the number of child item rows to rows . If this is less than PySide.QtGui.QStandardItem.rowCount() , the data in the unwanted rows is discarded.

    PySide.QtGui.QStandardItem. setSelectable ( selectable )
    参数: selectable PySide.QtCore.bool

    Sets whether the item is selectable. If selectable is true, the item can be selected by the user; otherwise, the user cannot select the item.

    You can control the selection behavior and mode by manipulating their view properties; see QAbstractItemView.selectionMode and QAbstractItemView.selectionBehavior .

    PySide.QtGui.QStandardItem. setSizeHint ( sizeHint )
    参数: sizeHint PySide.QtCore.QSize

    Sets the size hint for the 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.QStandardItem. setStatusTip ( statusTip )
    参数: statusTip – unicode

    Sets the item's status tip to the string specified by statusTip .

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

    Sets the item's text to the text 指定。

    PySide.QtGui.QStandardItem. setTextAlignment ( textAlignment )
    参数: textAlignment PySide.QtCore.Qt.Alignment
    PySide.QtGui.QStandardItem. setToolTip ( toolTip )
    参数: toolTip – unicode

    Sets the item's tooltip to the string specified by toolTip .

    PySide.QtGui.QStandardItem. setTristate ( tristate )
    参数: tristate PySide.QtCore.bool

    Sets whether the item is tristate. If tristate is true, the item is checkable with three separate states; otherwise, the item is checkable with two states. (Note that this also requires that the item is checkable; see PySide.QtGui.QStandardItem.isCheckable() .)

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

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

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

    Returns the size hint set for the item, or an invalid PySide.QtCore.QSize if no size hint has been set.

    If no size hint has been set, the item delegate will compute the size hint based on the item data.

    PySide.QtGui.QStandardItem. sortChildren ( column [ , order=Qt.AscendingOrder ] )
    参数:
    • column PySide.QtCore.int
    • order PySide.QtCore.Qt.SortOrder
    PySide.QtGui.QStandardItem. statusTip ( )
    返回类型: unicode

    Returns the item's status tip.

    PySide.QtGui.QStandardItem. takeChild ( row [ , column=0 ] )
    参数:
    • row PySide.QtCore.int
    • column PySide.QtCore.int
    返回类型:

    PySide.QtGui.QStandardItem

    Removes the child item at ( row , column ) without deleting it, and returns a pointer to the item. If there was no child at the given location, then this function returns 0.

    Note that this function, unlike PySide.QtGui.QStandardItem.takeRow() and PySide.QtGui.QStandardItem.takeColumn() , does not affect the dimensions of the child table.

    PySide.QtGui.QStandardItem. takeColumn ( column )
    参数: column PySide.QtCore.int
    返回类型:

    移除 column without deleting the column items, and returns a list of pointers to the removed items. For items in the column that have not been set, the corresponding pointers in the list will be 0.

    PySide.QtGui.QStandardItem. takeRow ( row )
    参数: row PySide.QtCore.int
    返回类型:

    移除 row without deleting the row items, and returns a list of pointers to the removed items. For items in the row that have not been set, the corresponding pointers in the list will be 0.

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

    Returns the item's text. This is the text that's presented to the user in a view.

    PySide.QtGui.QStandardItem. textAlignment ( )
    返回类型: PySide.QtCore.Qt.Alignment

    Returns the text alignment for the item's text.

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

    Returns the item's tooltip.

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

    Returns the type of this item. The type is used to distinguish custom items from the base class. When subclassing PySide.QtGui.QStandardItem , you should reimplement this function and return a new value greater than or equal to UserType .

    另请参阅

    QStandardItem.Type

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

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

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

    把项写入流 out . Only the data and flags of the item are written, not the child items.