Skip to content

PythonQt.QtGui.QTableWidgetItem

QTableWidgetItem

PythonQtInstanceWrapper object

Native bases: PythonQtInstanceWrapper

Supplemental documentation: Qt 5 reference:

Detailed Description

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 with the QTableWidget class.

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 Qt::ItemFlags). Checkable items can be checked and unchecked with the setCheckState() function. The corresponding checkState() function indicates whether the item is currently checked.

Subclassing

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.

Source: https://doc.qt.io/archives/qt-5.15/qtablewidgetitem.html

Complete member index

Every captured member retains its own identity. Identical captured declaration text is linked once; this does not establish native inheritance or interchangeable objects.

Member Kind Signature Summary
ItemType attribute type Convert a number or string to an integer, or return 0 if no arguments are given. (shared captured text)
Type attribute Any (shared captured text)
UserType attribute Any (shared captured text)
__init__ function (self, *args: Any, **kwargs: Any) -> None Native constructor; consult class documentation for supported overloads. (shared captured text)
background function (self) -> Any X.background() -> PythonQt.QtGui.QBrush
checkState function (self) -> Any Returns the checked state of the table item.
className function (self, *args: Any, **kwargs: Any) -> Any Return the classname of the object (shared captured text)
clone function (self) -> Any X.clone() -> PythonQt.QtGui.QTableWidgetItem
column function (self) -> int X.column() -> int
data function (self, role: int) -> Any X.data(role) -> object
delete function (self, *args: Any, **kwargs: Any) -> Any Deletes the C++ object (at your own risk, my friend!) (shared captured text)
flags function (self) -> Any Returns the flags used to describe the item.
font function (self) -> Any X.font() -> PythonQt.QtGui.QFont
foreground function (self) -> Any X.foreground() -> PythonQt.QtGui.QBrush
help function (self, *args: Any, **kwargs: Any) -> Any Shows the help of available methods for this class (shared captured text)
icon function (self) -> Any X.icon() -> PythonQt.QtGui.QIcon
inherits function (self, *args: Any, **kwargs: Any) -> Any Returns if the class inherits or is of given type name (shared captured text)
isSelected function (self) -> bool X.isSelected() -> bool
read function (self, *args: Any, **kwargs: Any) -> None Reads the item from stream in.
readFrom function (self, *args: Any, **kwargs: Any) -> Any (shared captured text)
row function (self) -> int X.row() -> int
setBackground function (self, brush: Any) -> None Sets the item's background brush to the specified brush.
setCheckState function (self, state: Any) -> None Sets the check state of the table item to be state.
setData function (self, role: int, value: Any) -> None X.setData(role, value)
setFlags function (self, arg0: flags) -> None Sets the flags for the item to the given flags.
setFont function (self, font: Any) -> None Sets the font used to display the item's text to the given font.
setForeground function (self, brush: Any) -> None Sets the item's foreground brush to the specified brush.
setIcon function (self, icon: Any) -> None Sets the item's icon to the icon specified.
setSelected function (self, select: bool) -> None Sets the selected state of the item to select.
setSizeHint function (self, size: Any) -> None Sets the size hint for the table item to be size.
setStatusTip function (self, statusTip: str) -> None Sets the status tip for the table item to the text specified by statusTip.
setText function (self, text: str) -> None Sets the item's text to the text specified.
setTextAlignment function (self, alignment: int) -> None Sets the text alignment for the item's text to the alignment specified.
setToolTip function (self, toolTip: str) -> None Sets the item's tooltip to the string specified by toolTip.
setWhatsThis function (self, whatsThis: str) -> None Sets the item's "What's This?" help to the string specified by whatsThis.
sizeHint function (self) -> Any X.sizeHint() -> PythonQt.QtCore.QSize
statusTip function (self) -> str X.statusTip() -> str
tableWidget function (self) -> Any X.tableWidget() -> PythonQt.QtGui.QTableWidget
text function (self) -> str X.text() -> str
textAlignment function (self) -> int X.textAlignment() -> int
toolTip function (self) -> str X.toolTip() -> str
type function (self) -> int X.type() -> int
whatsThis function (self) -> str X.whatsThis() -> str
write function (self, out: Any) -> None Writes the item to stream out.
writeTo function (self, out: Any) -> Any (shared captured text)