QTableWidgetItem Class Reference

[ QtGui module]

QTableWidgetItem 类提供项为用于 QTableWidget 类。 更多...

类型

方法

Special Methods


详细描述

QTableWidgetItem 类提供项为用于 QTableWidget 类。

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

The QTableWidgetItem class is a convenience class that replaces the QTableItem class in Qt 3. It provides an item for use 采用 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 () 函数。 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 () 和 setForeground () functions, and read with font () 和 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 Qt.ItemFlags ). Checkable items can be checked and unchecked with the setCheckState () 函数。 The corresponding checkState () function indicates whether the item is currently checked.

子类化

When subclassing 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 .


类型文档编制

QTableWidgetItem.ItemType

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

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

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

另请参阅 type ().


方法文档编制

QTableWidgetItem.__init__ ( self , int  type  = QTableWidgetItem.Type)

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

另请参阅 type ().

QTableWidgetItem.__init__ ( self , QString  text , int  type  = QTableWidgetItem.Type)

Constructs a table item with the given text .

另请参阅 type ().

QTableWidgetItem.__init__ ( self , QIcon   icon , QString  text , int  type  = QTableWidgetItem.Type)

Constructs a table item with the given icon and text .

另请参阅 type ().

QTableWidgetItem.__init__ ( self , QTableWidgetItem   other )

构造副本为 other 。注意 type () 和 tableWidget () are not copied.

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

该函数在 Qt 4.1 引入。

另请参阅 data () and flags ().

QBrush QTableWidgetItem.background ( self )

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

该函数在 Qt 4.2 引入。

另请参阅 setBackground () 和 foreground ().

QColor QTableWidgetItem.backgroundColor ( self )

Qt.CheckState QTableWidgetItem.checkState ( self )

Returns the checked state of the table item.

另请参阅 setCheckState () 和 flags ().

QTableWidgetItem QTableWidgetItem.clone ( self )

Creates a copy of the item.

int QTableWidgetItem.column ( self )

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

该函数在 Qt 4.2 引入。

另请参阅 row ().

QVariant QTableWidgetItem.data ( self , int  role )

Returns the item's data for the given role .

另请参阅 setData ().

Qt.ItemFlags QTableWidgetItem.flags ( self )

Returns the flags used to describe the item. These determine whether the item can be checked, edited, and selected.

另请参阅 setFlags ().

QFont QTableWidgetItem.font ( self )

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

另请参阅 setFont ().

QBrush QTableWidgetItem.foreground ( self )

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

该函数在 Qt 4.2 引入。

另请参阅 setForeground () 和 background ().

QIcon QTableWidgetItem.icon ( self )

Returns the item's icon.

另请参阅 setIcon () 和 iconSize .

bool QTableWidgetItem.isSelected ( self )

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

该函数在 Qt 4.2 引入。

另请参阅 setSelected ().

QTableWidgetItem.read ( self , QDataStream   in )

读取项从流 in .

另请参阅 write ().

int QTableWidgetItem.row ( self )

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

该函数在 Qt 4.2 引入。

另请参阅 column ().

QTableWidgetItem.setBackground ( self , QBrush   brush )

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

该函数在 Qt 4.2 引入。

另请参阅 background () 和 setForeground ().

QTableWidgetItem.setBackgroundColor ( self , QColor   color )

QTableWidgetItem.setCheckState ( self , Qt.CheckState   state )

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

另请参阅 checkState ().

QTableWidgetItem.setData ( self , int  role , QVariant  value )

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

另请参阅 Qt.ItemDataRole and data ().

QTableWidgetItem.setFlags ( self , Qt.ItemFlags   aflags )

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

另请参阅 flags ().

QTableWidgetItem.setFont ( self , QFont   afont )

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

另请参阅 font (), setText (),和 setForeground ().

QTableWidgetItem.setForeground ( self , QBrush   brush )

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

该函数在 Qt 4.2 引入。

另请参阅 foreground () 和 setBackground ().

QTableWidgetItem.setIcon ( self , QIcon   aicon )

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

另请参阅 icon (), setText (),和 iconSize .

QTableWidgetItem.setSelected ( self , bool  aselect )

将项的选定状态设为 select .

该函数在 Qt 4.2 引入。

另请参阅 isSelected ().

QTableWidgetItem.setSizeHint ( self , QSize   size )

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.

该函数在 Qt 4.1 引入。

另请参阅 sizeHint ().

QTableWidgetItem.setStatusTip ( self , QString  astatusTip )

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

另请参阅 statusTip (), setToolTip (),和 setWhatsThis ().

QTableWidgetItem.setText ( self , QString  atext )

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

另请参阅 text (), setFont (),和 setForeground ().

QTableWidgetItem.setTextAlignment ( self , int  alignment )

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

另请参阅 textAlignment () 和 Qt.Alignment .

QTableWidgetItem.setTextColor ( self , QColor   color )

QTableWidgetItem.setToolTip ( self , QString  atoolTip )

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

另请参阅 toolTip (), setStatusTip (),和 setWhatsThis ().

QTableWidgetItem.setWhatsThis ( self , QString  awhatsThis )

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

另请参阅 whatsThis (), setStatusTip (),和 setToolTip ().

QSize QTableWidgetItem.sizeHint ( self )

Returns the size hint set for the table item.

该函数在 Qt 4.1 引入。

另请参阅 setSizeHint ().

QString QTableWidgetItem.statusTip ( self )

Returns the item's status tip.

另请参阅 setStatusTip ().

QTableWidget QTableWidgetItem.tableWidget ( self )

Returns the table widget that contains the item.

QString QTableWidgetItem.text ( self )

返回项的文本。

另请参阅 setText ().

int QTableWidgetItem.textAlignment ( self )

Returns the text alignment for the item's text.

另请参阅 setTextAlignment () 和 Qt.Alignment .

QColor QTableWidgetItem.textColor ( self )

QString QTableWidgetItem.toolTip ( self )

Returns the item's tooltip.

另请参阅 setToolTip ().

int QTableWidgetItem.type ( self )

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

QString QTableWidgetItem.whatsThis ( self )

Returns the item's "What's This?" help.

另请参阅 setWhatsThis ().

QTableWidgetItem.write ( self , QDataStream   out )

把项写入流 out .

另请参阅 read ().

bool QTableWidgetItem.__ge__ ( self , QTableWidgetItem   other )

bool QTableWidgetItem.__lt__ ( self , QTableWidgetItem   other )