The PySide.QtGui.QTableWidgetItem class provides an item for use with the PySide.QtGui.QTableWidget class.
Table items are used to hold pieces of information for table widgets. Items usually contain text, icons, or checkboxes
The 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 class.
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 ). Checkable items can be checked and unchecked with the PySide.QtGui.QTableWidgetItem.setCheckState() function. The corresponding PySide.QtGui.QTableWidgetItem.checkState() function indicates whether the item is currently checked.
When subclassing 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 .
See also
PySide.QtGui.QTableWidget Model/View Programming PySide.QtGui.QListWidgetItem PySide.QtGui.QTreeWidgetItem
Parameters: |
|
---|
Constructs a table item with the given icon and text .
See also
Constructs a table item with the given text .
See also
Constructs a copy of other . Note that PySide.QtGui.QTableWidgetItem.type() and PySide.QtGui.QTableWidgetItem.tableWidget() are not copied.
This function is useful when reimplementing PySide.QtGui.QTableWidgetItem.clone() .
Constructs a table item of the specified type that does not belong to any table.
See also
This enum describes the types that are used to describe table widget items.
Constant | Description |
---|---|
QTableWidgetItem.Type | The default type for table widget items. |
QTableWidgetItem.UserType | The minimum value for custom types. Values below UserType are reserved by Qt. |
You can define new user types in PySide.QtGui.QTableWidgetItem subclasses to ensure that custom items are treated specially.
See also
Return type: | PySide.QtGui.QBrush |
---|
Returns the brush used to render the item’s background.
Return type: | PySide.QtCore.Qt.CheckState |
---|
Returns the checked state of the table item.
Return type: | PySide.QtGui.QTableWidgetItem |
---|
Creates a copy of the item.
Return type: | 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.
See also
Parameters: | role – PySide.QtCore.int |
---|---|
Return type: | object |
Returns the item’s data for the given role .
Return type: | PySide.QtCore.Qt.ItemFlags |
---|
Returns the flags used to describe the item. These determine whether the item can be checked, edited, and selected.
Return type: | PySide.QtGui.QFont |
---|
Returns the font used to render the item’s text.
Return type: | PySide.QtGui.QBrush |
---|
Returns the brush used to render the item’s foreground (e.g. text).
Return type: | PySide.QtGui.QIcon |
---|
Returns the item’s icon.
Return type: | PySide.QtCore.bool |
---|
Returns true if the item is selected, otherwise returns false.
Parameters: | other – PySide.QtGui.QTableWidgetItem |
---|---|
Return type: | PySide.QtCore.bool |
Returns true if the item is less than the other item; otherwise returns false.
Parameters: | in – PySide.QtCore.QDataStream |
---|
Reads the item from stream in .
Return type: | 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.
Parameters: | brush – PySide.QtGui.QBrush |
---|
Sets the item’s background brush to the specified brush .
Parameters: | state – PySide.QtCore.Qt.CheckState |
---|
Parameters: |
|
---|
Sets the item’s data for the given role to the specified value .
See also
Qt.ItemDataRole PySide.QtGui.QTableWidgetItem.data()
Parameters: | flags – PySide.QtCore.Qt.ItemFlags |
---|
Parameters: | font – PySide.QtGui.QFont |
---|
Sets the font used to display the item’s text to the given font .
Parameters: | brush – PySide.QtGui.QBrush |
---|
Sets the item’s foreground brush to the specified brush .
Parameters: | icon – PySide.QtGui.QIcon |
---|
Sets the item’s icon to the icon specified.
Parameters: | select – PySide.QtCore.bool |
---|
Sets the selected state of the item to select .
Parameters: | 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.
Parameters: | statusTip – unicode |
---|
Sets the status tip for the table item to the text specified by statusTip . PySide.QtGui.QTableWidget mouse tracking needs to be enabled for this feature to work.
Parameters: | text – unicode |
---|
Sets the item’s text to the text specified.
Parameters: | alignment – PySide.QtCore.int |
---|
Sets the text alignment for the item’s text to the alignment specified.
See also
PySide.QtGui.QTableWidgetItem.textAlignment() Qt.Alignment
Parameters: | toolTip – unicode |
---|
Sets the item’s tooltip to the string specified by toolTip .
Parameters: | whatsThis – unicode |
---|
Sets the item’s “What’s This?” help to the string specified by whatsThis .
Return type: | PySide.QtCore.QSize |
---|
Returns the size hint set for the table item.
Return type: | unicode |
---|
Returns the item’s status tip.
Return type: | PySide.QtGui.QTableWidget |
---|
Returns the table widget that contains the item.
Return type: | unicode |
---|
Returns the item’s text.
Return type: | PySide.QtCore.int |
---|
Returns the text alignment for the item’s text.
See also
PySide.QtGui.QTableWidgetItem.setTextAlignment() Qt.Alignment
Return type: | unicode |
---|
Returns the item’s tooltip.
Return type: | PySide.QtCore.int |
---|
Returns the type passed to the PySide.QtGui.QTableWidgetItem constructor.
Return type: | unicode |
---|
Returns the item’s “What’s This?” help.
Parameters: | out – PySide.QtCore.QDataStream |
---|
Writes the item to stream out .
See also