内容表

上一话题

QTableWidget

下一话题

QTableWidgetSelectionRange

QTableWidgetItem

QTableWidgetItem class provides an item for use with the QTableWidget 类。 更多

Inheritance diagram of PySide2.QtWidgets.QTableWidgetItem

概要

函数

虚函数

详细描述

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

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

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

QTableWidgetItem *newItem = new QTableWidgetItem(tr("%1").arg(
    pow(row, column+1)));
tableWidget->setItem(row, column, newItem);
											

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

子类化

当子类化 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 QTableWidgetItem ( icon , text [ , type=Type ] )

QTableWidgetItem(text[, type=Type])

QTableWidgetItem(other)

QTableWidgetItem([type=Type])

param type

int

param icon

QIcon

param other

QTableWidgetItem

param text

unicode

Constructs a table item with the given icon and text .

另请参阅

type()

Constructs a table item with the given text .

另请参阅

type()

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

另请参阅

type()

PySide2.QtWidgets.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 are reserved by Qt.

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

另请参阅

type()

PySide2.QtWidgets.QTableWidgetItem. background ( )
返回类型

QBrush

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

PySide2.QtWidgets.QTableWidgetItem. backgroundColor ( )
返回类型

QColor

注意

此函数被弃用。

This function is deprecated. Use background() 代替。

PySide2.QtWidgets.QTableWidgetItem. checkState ( )
返回类型

CheckState

Returns the checked state of the table item.

PySide2.QtWidgets.QTableWidgetItem. clone ( )
返回类型

QTableWidgetItem

Creates a copy of the item.

PySide2.QtWidgets.QTableWidgetItem. column ( )
返回类型

int

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

另请参阅

row()

PySide2.QtWidgets.QTableWidgetItem. data ( role )
参数

role int

返回类型

object

Returns the item’s data for the given role .

另请参阅

setData()

PySide2.QtWidgets.QTableWidgetItem. flags ( )
返回类型

ItemFlags

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

另请参阅

setFlags()

PySide2.QtWidgets.QTableWidgetItem. font ( )
返回类型

QFont

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

另请参阅

setFont()

PySide2.QtWidgets.QTableWidgetItem. foreground ( )
返回类型

QBrush

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

PySide2.QtWidgets.QTableWidgetItem. icon ( )
返回类型

QIcon

Returns the item’s icon.

PySide2.QtWidgets.QTableWidgetItem. isSelected ( )
返回类型

bool

返回 true 若项被选中,否则返回 false .

另请参阅

setSelected()

PySide2.QtWidgets.QTableWidgetItem. __lt__ ( other )
参数

other QTableWidgetItem

返回类型

bool

PySide2.QtWidgets.QTableWidgetItem. read ( in )
参数

in QDataStream

读取项从流 in .

另请参阅

write()

PySide2.QtWidgets.QTableWidgetItem. row ( )
返回类型

int

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

另请参阅

column()

PySide2.QtWidgets.QTableWidgetItem. setBackground ( brush )
参数

brush QBrush

Sets the item’s background brush to the specified brush 。设置默认构造的笔刷将使视图使用来自样式的默认颜色。

PySide2.QtWidgets.QTableWidgetItem. setBackgroundColor ( color )
参数

color QColor

注意

此函数被弃用。

This function is deprecated. Use setBackground() 代替。

另请参阅

backgroundColor()

PySide2.QtWidgets.QTableWidgetItem. setCheckState ( state )
参数

state CheckState

Sets the check state of the table item to be state .

另请参阅

checkState()

PySide2.QtWidgets.QTableWidgetItem. setData ( role , value )
参数
  • role int

  • value – object

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

注意

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

另请参阅

ItemDataRole data()

PySide2.QtWidgets.QTableWidgetItem. setFlags ( flags )
参数

flags ItemFlags

将项的标志设为给定 flags . These determine whether the item can be selected or modified.

另请参阅

flags()

PySide2.QtWidgets.QTableWidgetItem. setFont ( font )
参数

font QFont

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

PySide2.QtWidgets.QTableWidgetItem. setForeground ( brush )
参数

brush QBrush

Sets the item’s foreground brush to the specified brush 。设置默认构造的笔刷将使视图使用来自样式的默认颜色。

PySide2.QtWidgets.QTableWidgetItem. setIcon ( icon )
参数

icon QIcon

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

PySide2.QtWidgets.QTableWidgetItem. setSelected ( select )
参数

select bool

将项的选定状态设为 select .

另请参阅

isSelected()

PySide2.QtWidgets.QTableWidgetItem. setSizeHint ( size )
参数

size QSize

Sets the size hint for the table item to be size 。若没有设置尺寸提示或 size 无效,项委托将基于项数据计算尺寸提示。

另请参阅

sizeHint()

PySide2.QtWidgets.QTableWidgetItem. setStatusTip ( statusTip )
参数

statusTip – unicode

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

PySide2.QtWidgets.QTableWidgetItem. setText ( text )
参数

text – unicode

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

PySide2.QtWidgets.QTableWidgetItem. setTextAlignment ( alignment )
参数

alignment int

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

另请参阅

textAlignment() Alignment

PySide2.QtWidgets.QTableWidgetItem. setTextColor ( color )
参数

color QColor

注意

此函数被弃用。

This function is deprecated. Use setForeground() 代替。

另请参阅

textColor()

PySide2.QtWidgets.QTableWidgetItem. setToolTip ( toolTip )
参数

toolTip – unicode

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

PySide2.QtWidgets.QTableWidgetItem. setWhatsThis ( whatsThis )
参数

whatsThis – unicode

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

PySide2.QtWidgets.QTableWidgetItem. sizeHint ( )
返回类型

QSize

Returns the size hint set for the table item.

另请参阅

setSizeHint()

PySide2.QtWidgets.QTableWidgetItem. statusTip ( )
返回类型

unicode

Returns the item’s status tip.

另请参阅

setStatusTip()

PySide2.QtWidgets.QTableWidgetItem. tableWidget ( )
返回类型

QTableWidget

Returns the table widget that contains the item.

PySide2.QtWidgets.QTableWidgetItem. text ( )
返回类型

unicode

Returns the item’s text.

另请参阅

setText()

PySide2.QtWidgets.QTableWidgetItem. textAlignment ( )
返回类型

int

Returns the text alignment for the item’s text.

另请参阅

setTextAlignment() Alignment

PySide2.QtWidgets.QTableWidgetItem. textColor ( )
返回类型

QColor

注意

此函数被弃用。

This function is deprecated. Use foreground() 代替。

另请参阅

setTextColor()

PySide2.QtWidgets.QTableWidgetItem. toolTip ( )
返回类型

unicode

Returns the item’s tooltip.

另请参阅

setToolTip()

PySide2.QtWidgets.QTableWidgetItem. type ( )
返回类型

int

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

PySide2.QtWidgets.QTableWidgetItem. whatsThis ( )
返回类型

unicode

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

另请参阅

setWhatsThis()

PySide2.QtWidgets.QTableWidgetItem. write ( out )
参数

out QDataStream

把项写入流 out .

另请参阅

read()