QTableWidgetItem

概要

函数

虚函数

详细描述

PySide.QtGui.QTableWidgetItem class provides an item for use with the PySide.QtGui.QTableWidget 类。

Table items are used to hold pieces of information for table widgets. Items usually contain text, icons, or checkboxes

PySide.QtGui.QTableWidgetItem class is a convenience class that replaces the QTableItem class in Qt 3. It provides an item for use with the PySide.QtGui.QTableWidget 类。

Top-level items are constructed without a parent then inserted at the position specified by a pair of row and column numbers:

newItem = QTableWidgetItem(tr("%s" % pow(row, column+1)))
tableWidget.setItem(row, column, newItem)
										

Each item can have its own background brush which is set with the PySide.QtGui.QTableWidgetItem.setBackground() function. The current background brush can be found with PySide.QtGui.QTableWidgetItem.background() . The text label for each item can be rendered with its own font and brush. These are specified with the PySide.QtGui.QTableWidgetItem.setFont() and PySide.QtGui.QTableWidgetItem.setForeground() functions, and read with PySide.QtGui.QTableWidgetItem.font() and PySide.QtGui.QTableWidgetItem.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.QTableWidgetItem.setFlags() with the appropriate value (see Qt.ItemFlags )。可复选项可以被复选和取消复选采用 PySide.QtGui.QTableWidgetItem.setCheckState() function. The corresponding PySide.QtGui.QTableWidgetItem.checkState() function indicates whether the item is currently checked.

子类化

当子类化 PySide.QtGui.QTableWidgetItem to provide custom items, it is possible to define new types for them so that they can be distinguished from standard items. The constructors for subclasses that require this feature need to call the base class constructor with a new type value equal to or greater than UserType .

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

Constructs a table item with the given icon and text .

Constructs a table item with the given text .

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

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

Constructs a table item of the specified type that does not belong to any table.

PySide.QtGui.QTableWidgetItem. ItemType

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

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

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

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

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

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

Returns the checked state of the table item.

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

Creates a copy of the item.

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

Returns the column of the item in the table. If the item is not in a table, this function will return -1.

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

Returns the item's data for the given role .

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

返回用于描述项的标志。这些确定项是否可以被复选、编辑及选择。

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

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

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

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

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

Returns the item's icon.

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

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

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

Returns true if the item is less than the other item; otherwise returns false.

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

读取项从流 in .

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

Returns the row of the item in the table. If the item is not in a table, this function will return -1.

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

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

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

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

另请参阅

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

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

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

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

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

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

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

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

将项的选定状态设为 select .

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

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

Sets the status tip for the table item to the text specified by statusTip . PySide.QtGui.QTableWidget 鼠标跟踪需要被启用此特征才工作。

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

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

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

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

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

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

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

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

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

Returns the size hint set for the table item.

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

Returns the item's status tip.

PySide.QtGui.QTableWidgetItem. tableWidget ( )
返回类型: PySide.QtGui.QTableWidget

Returns the table widget that contains the item.

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

返回项的文本。

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

Returns the text alignment for the item's text.

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

Returns the item's tooltip.

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

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

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

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

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

把项写入流 out .