QTableWidgetItem

Synopsis

Functions

Virtual functions

Detailed Description

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.

Subclassing

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 .

class PySide.QtGui.QTableWidgetItem(icon, text[, type=Type])
class PySide.QtGui.QTableWidgetItem(text[, type=Type])
class PySide.QtGui.QTableWidgetItem(other)
class PySide.QtGui.QTableWidgetItem([type=Type])
Parameters:

Constructs a table item with the given icon and text .

Constructs a table item with the given text .

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.

PySide.QtGui.QTableWidgetItem.ItemType

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.

PySide.QtGui.QTableWidgetItem.background()
Return type:PySide.QtGui.QBrush

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

PySide.QtGui.QTableWidgetItem.checkState()
Return type:PySide.QtCore.Qt.CheckState

Returns the checked state of the table item.

PySide.QtGui.QTableWidgetItem.clone()
Return type:PySide.QtGui.QTableWidgetItem

Creates a copy of the item.

PySide.QtGui.QTableWidgetItem.column()
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.

PySide.QtGui.QTableWidgetItem.data(role)
Parameters:rolePySide.QtCore.int
Return type:object

Returns the item’s data for the given role .

PySide.QtGui.QTableWidgetItem.flags()
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.

PySide.QtGui.QTableWidgetItem.font()
Return type:PySide.QtGui.QFont

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

PySide.QtGui.QTableWidgetItem.foreground()
Return type:PySide.QtGui.QBrush

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

PySide.QtGui.QTableWidgetItem.icon()
Return type:PySide.QtGui.QIcon

Returns the item’s icon.

PySide.QtGui.QTableWidgetItem.isSelected()
Return type:PySide.QtCore.bool

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

PySide.QtGui.QTableWidgetItem.__lt__(other)
Parameters:otherPySide.QtGui.QTableWidgetItem
Return type:PySide.QtCore.bool

Returns true if the item is less than the other item; otherwise returns false.

PySide.QtGui.QTableWidgetItem.read(in)
Parameters:inPySide.QtCore.QDataStream

Reads the item from stream in .

PySide.QtGui.QTableWidgetItem.row()
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.

PySide.QtGui.QTableWidgetItem.setBackground(brush)
Parameters:brushPySide.QtGui.QBrush

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

PySide.QtGui.QTableWidgetItem.setCheckState(state)
Parameters:statePySide.QtCore.Qt.CheckState
PySide.QtGui.QTableWidgetItem.setData(role, value)
Parameters:
  • rolePySide.QtCore.int
  • value – object

Sets the item’s data for the given role to the specified value .

See also

Qt.ItemDataRole PySide.QtGui.QTableWidgetItem.data()

PySide.QtGui.QTableWidgetItem.setFlags(flags)
Parameters:flagsPySide.QtCore.Qt.ItemFlags
PySide.QtGui.QTableWidgetItem.setFont(font)
Parameters:fontPySide.QtGui.QFont

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

PySide.QtGui.QTableWidgetItem.setForeground(brush)
Parameters:brushPySide.QtGui.QBrush

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

PySide.QtGui.QTableWidgetItem.setIcon(icon)
Parameters:iconPySide.QtGui.QIcon

Sets the item’s icon to the icon specified.

PySide.QtGui.QTableWidgetItem.setSelected(select)
Parameters:selectPySide.QtCore.bool

Sets the selected state of the item to select .

PySide.QtGui.QTableWidgetItem.setSizeHint(size)
Parameters:sizePySide.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.

PySide.QtGui.QTableWidgetItem.setStatusTip(statusTip)
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.

PySide.QtGui.QTableWidgetItem.setText(text)
Parameters:text – unicode

Sets the item’s text to the text specified.

PySide.QtGui.QTableWidgetItem.setTextAlignment(alignment)
Parameters:alignmentPySide.QtCore.int

Sets the text alignment for the item’s text to the alignment specified.

PySide.QtGui.QTableWidgetItem.setToolTip(toolTip)
Parameters:toolTip – unicode

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

PySide.QtGui.QTableWidgetItem.setWhatsThis(whatsThis)
Parameters:whatsThis – unicode

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

PySide.QtGui.QTableWidgetItem.sizeHint()
Return type:PySide.QtCore.QSize

Returns the size hint set for the table item.

PySide.QtGui.QTableWidgetItem.statusTip()
Return type:unicode

Returns the item’s status tip.

PySide.QtGui.QTableWidgetItem.tableWidget()
Return type:PySide.QtGui.QTableWidget

Returns the table widget that contains the item.

PySide.QtGui.QTableWidgetItem.text()
Return type:unicode

Returns the item’s text.

PySide.QtGui.QTableWidgetItem.textAlignment()
Return type:PySide.QtCore.int

Returns the text alignment for the item’s text.

PySide.QtGui.QTableWidgetItem.toolTip()
Return type:unicode

Returns the item’s tooltip.

PySide.QtGui.QTableWidgetItem.type()
Return type:PySide.QtCore.int

Returns the type passed to the PySide.QtGui.QTableWidgetItem constructor.

PySide.QtGui.QTableWidgetItem.whatsThis()
Return type:unicode

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

PySide.QtGui.QTableWidgetItem.write(out)
Parameters:outPySide.QtCore.QDataStream

Writes the item to stream out .