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 .
| 参数: |
|
|---|
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.
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.QBrush |
|---|
Returns the brush used to render the item's background.
| 返回类型: | PySide.QtCore.Qt.CheckState |
|---|
Returns the checked state of the table item.
| 返回类型: | PySide.QtGui.QTableWidgetItem |
|---|
Creates a copy of the item.
| 返回类型: | 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.
| 参数: | role – PySide.QtCore.int |
|---|---|
| 返回类型: | object |
Returns the item's data for the given role .
| 返回类型: | PySide.QtCore.Qt.ItemFlags |
|---|
返回用于描述项的标志。这些确定项是否可以被复选、编辑及选择。
| 返回类型: | PySide.QtGui.QFont |
|---|
Returns the font used to render the item's text.
| 返回类型: | PySide.QtGui.QBrush |
|---|
Returns the brush used to render the item's foreground (e.g. text).
| 返回类型: | PySide.QtGui.QIcon |
|---|
Returns the item's icon.
| 返回类型: | PySide.QtCore.bool |
|---|
Returns true if the item is selected, otherwise returns false.
| 参数: | other – PySide.QtGui.QTableWidgetItem |
|---|---|
| 返回类型: | PySide.QtCore.bool |
Returns true if the item is less than the other item; otherwise returns false.
| 参数: | in – PySide.QtCore.QDataStream |
|---|
读取项从流 in .
| 返回类型: | 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.
| 参数: | brush – PySide.QtGui.QBrush |
|---|
Sets the item's background brush to the specified brush .
| 参数: | state – PySide.QtCore.Qt.CheckState |
|---|
| 参数: |
|
|---|
Sets the item's data for the given role 到指定 value .
另请参阅
Qt.ItemDataRole PySide.QtGui.QTableWidgetItem.data()
| 参数: | flags – PySide.QtCore.Qt.ItemFlags |
|---|
| 参数: | font – PySide.QtGui.QFont |
|---|
Sets the font used to display the item's text to the given font .
| 参数: | brush – PySide.QtGui.QBrush |
|---|
Sets the item's foreground brush to the specified brush .
| 参数: | icon – PySide.QtGui.QIcon |
|---|
Sets the item's icon to the icon 指定。
| 参数: | select – PySide.QtCore.bool |
|---|
将项的选定状态设为 select .
| 参数: | 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.
| 参数: | statusTip – unicode |
|---|
Sets the status tip for the table item to the text specified by statusTip . PySide.QtGui.QTableWidget 鼠标跟踪需要被启用此特征才工作。
| 参数: | text – unicode |
|---|
Sets the item's text to the text 指定。
| 参数: | alignment – PySide.QtCore.int |
|---|
Sets the text alignment for the item's text to the alignment 指定。
另请参阅
PySide.QtGui.QTableWidgetItem.textAlignment() Qt.Alignment
| 参数: | toolTip – unicode |
|---|
Sets the item's tooltip to the string specified by toolTip .
| 参数: | whatsThis – unicode |
|---|
Sets the item's “What's This?” help to the string specified by whatsThis .
| 返回类型: | PySide.QtCore.QSize |
|---|
Returns the size hint set for the table item.
| 返回类型: | unicode |
|---|
Returns the item's status tip.
| 返回类型: | PySide.QtGui.QTableWidget |
|---|
Returns the table widget that contains the item.
| 返回类型: | unicode |
|---|
返回项的文本。
| 返回类型: | PySide.QtCore.int |
|---|
Returns the text alignment for the item's text.
另请参阅
PySide.QtGui.QTableWidgetItem.setTextAlignment() Qt.Alignment
| 返回类型: | unicode |
|---|
Returns the item's tooltip.
| 返回类型: | PySide.QtCore.int |
|---|
返回类型被传递给 PySide.QtGui.QTableWidgetItem 构造函数。
| 返回类型: | unicode |
|---|
Returns the item's “What's This?” help.
| 参数: | out – PySide.QtCore.QDataStream |
|---|
把项写入流 out .