QTableWidgetItem 类提供项为用于 QTableWidget 类。 更多...
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 .
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 ().
Constructs a table item of the specified type that does not belong to any table.
另请参阅 type ().
Constructs a table item with the given text .
另请参阅 type ().
Constructs a table item with the given icon and text .
另请参阅 type ().
构造副本为 other 。注意 type () 和 tableWidget () are not copied.
此函数是有用的,当重实现 clone ().
该函数在 Qt 4.1 引入。
Returns the brush used to render the item's background.
该函数在 Qt 4.2 引入。
另请参阅 setBackground () 和 foreground ().
Returns the checked state of the table item.
另请参阅 setCheckState () 和 flags ().
Creates a copy of the item.
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 ().
Returns the item's data for the given role .
另请参阅 setData ().
Returns the flags used to describe the item. These determine whether the item can be checked, edited, and selected.
另请参阅 setFlags ().
Returns the font used to render the item's text.
另请参阅 setFont ().
Returns the brush used to render the item's foreground (e.g. text).
该函数在 Qt 4.2 引入。
另请参阅 setForeground () 和 background ().
Returns the item's icon.
Returns true if the item is selected, otherwise returns false.
该函数在 Qt 4.2 引入。
另请参阅 setSelected ().
读取项从流 in .
另请参阅 write ().
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 ().
Sets the item's background brush to the specified brush .
该函数在 Qt 4.2 引入。
另请参阅 background () 和 setForeground ().
Sets the check state of the table item to be state .
另请参阅 checkState ().
Sets the item's data for the given role 到指定 value .
另请参阅 Qt.ItemDataRole and data ().
将项的标志设为给定 flags . These determine whether the item can be selected or modified.
另请参阅 flags ().
Sets the font used to display the item's text to the given font .
另请参阅 font (), setText (),和 setForeground ().
Sets the item's foreground brush to the specified brush .
该函数在 Qt 4.2 引入。
另请参阅 foreground () 和 setBackground ().
Sets the item's icon to the icon 指定。
另请参阅 icon (), setText (),和 iconSize .
将项的选定状态设为 select .
该函数在 Qt 4.2 引入。
另请参阅 isSelected ().
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 ().
Sets the status tip for the table item to the text specified by statusTip . QTableWidget 鼠标跟踪需要被启用此特征才工作。
另请参阅 statusTip (), setToolTip (),和 setWhatsThis ().
Sets the item's text to the text 指定。
另请参阅 text (), setFont (),和 setForeground ().
Sets the text alignment for the item's text to the alignment 指定。
另请参阅 textAlignment () 和 Qt.Alignment .
Sets the item's tooltip to the string specified by toolTip .
另请参阅 toolTip (), setStatusTip (),和 setWhatsThis ().
Sets the item's "What's This?" help to the string specified by whatsThis .
另请参阅 whatsThis (), setStatusTip (),和 setToolTip ().
Returns the size hint set for the table item.
该函数在 Qt 4.1 引入。
另请参阅 setSizeHint ().
Returns the item's status tip.
另请参阅 setStatusTip ().
Returns the table widget that contains the item.
返回项的文本。
另请参阅 setText ().
Returns the text alignment for the item's text.
另请参阅 setTextAlignment () 和 Qt.Alignment .
Returns the item's tooltip.
另请参阅 setToolTip ().
返回类型被传递给 QTableWidgetItem 构造函数。
Returns the item's "What's This?" help.
另请参阅 setWhatsThis ().
把项写入流 out .
另请参阅 read ().