QTableWidgetItem¶
The QTableWidgetItem
class provides an item for use with the QTableWidget
class. More…

Synopsis¶
Functions¶
def
background
()def
checkState
()def
column
()def
flags
()def
font
()def
foreground
()def
icon
()def
isSelected
()def
row
()def
setBackground
(brush)def
setCheckState
(state)def
setFlags
(flags)def
setFont
(font)def
setForeground
(brush)def
setIcon
(icon)def
setSelected
(select)def
setSizeHint
(size)def
setStatusTip
(statusTip)def
setText
(text)def
setTextAlignment
(alignment)def
setToolTip
(toolTip)def
setWhatsThis
(whatsThis)def
sizeHint
()def
statusTip
()def
tableWidget
()def
text
()def
textAlignment
()def
toolTip
()def
type
()def
whatsThis
()
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 function. The current background brush can be found with . The text label for each item can be rendered with its own font and brush. These are specified with the and functions, and read with and .
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 with the appropriate value (see ItemFlags
). Checkable items can be checked and unchecked with the function. The corresponding 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
.
-
class
PySide6.QtWidgets.
QTableWidgetItem
(icon, text[, type=Type])¶ PySide6.QtWidgets.QTableWidgetItem(text[, type=Type])
PySide6.QtWidgets.QTableWidgetItem(other)
PySide6.QtWidgets.QTableWidgetItem([type=Type])
- Parameters
icon –
PySide6.QtGui.QIcon
text – str
type – int
Constructs a table item with the given icon
and text
.
See also
Constructs a table item with the given text
.
See also
Constructs a table item of the specified type
that does not belong to any table.
See also
-
PySide6.QtWidgets.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 are reserved by Qt.
You can define new user types in QTableWidgetItem
subclasses to ensure that custom items are treated specially.
See also
-
PySide6.QtWidgets.QTableWidgetItem.
background
()¶ - Return type
-
PySide6.QtWidgets.QTableWidgetItem.
checkState
()¶ - Return type
-
PySide6.QtWidgets.QTableWidgetItem.
clone
()¶ - Return type
Creates a copy of the item.
-
PySide6.QtWidgets.QTableWidgetItem.
column
()¶ - Return type
int
-
PySide6.QtWidgets.QTableWidgetItem.
data
(role)¶ - Parameters
role – int
- Return type
object
Returns the item’s data for the given role
.
See also
-
PySide6.QtWidgets.QTableWidgetItem.
flags
()¶ - Return type
ItemFlags
-
PySide6.QtWidgets.QTableWidgetItem.
font
()¶ - Return type
-
PySide6.QtWidgets.QTableWidgetItem.
foreground
()¶ - Return type
-
PySide6.QtWidgets.QTableWidgetItem.
icon
()¶ - Return type
-
PySide6.QtWidgets.QTableWidgetItem.
isSelected
()¶ - Return type
bool
-
PySide6.QtWidgets.QTableWidgetItem.
__lt__
(other)¶ - Parameters
- Return type
bool
-
PySide6.QtWidgets.QTableWidgetItem.
read
(in)¶ - Parameters
Reads the item from stream in
.
See also
-
PySide6.QtWidgets.QTableWidgetItem.
row
()¶ - Return type
int
-
PySide6.QtWidgets.QTableWidgetItem.
setBackground
(brush)¶ - Parameters
brush –
PySide6.QtGui.QBrush
-
PySide6.QtWidgets.QTableWidgetItem.
setCheckState
(state)¶ - Parameters
state –
CheckState
-
PySide6.QtWidgets.QTableWidgetItem.
setData
(role, value)¶ - Parameters
role – int
value – object
Sets the item’s data for the given role
to the specified value
.
Note
The default implementation treats EditRole
and DisplayRole
as referring to the same data.
See also
ItemDataRole
data()
-
PySide6.QtWidgets.QTableWidgetItem.
setFlags
(flags)¶ - Parameters
flags –
ItemFlags
-
PySide6.QtWidgets.QTableWidgetItem.
setFont
(font)¶ - Parameters
font –
PySide6.QtGui.QFont
-
PySide6.QtWidgets.QTableWidgetItem.
setForeground
(brush)¶ - Parameters
brush –
PySide6.QtGui.QBrush
-
PySide6.QtWidgets.QTableWidgetItem.
setIcon
(icon)¶ - Parameters
icon –
PySide6.QtGui.QIcon
-
PySide6.QtWidgets.QTableWidgetItem.
setSelected
(select)¶ - Parameters
select – bool
-
PySide6.QtWidgets.QTableWidgetItem.
setSizeHint
(size)¶ - Parameters
size –
PySide6.QtCore.QSize
-
PySide6.QtWidgets.QTableWidgetItem.
setStatusTip
(statusTip)¶ - Parameters
statusTip – str
-
PySide6.QtWidgets.QTableWidgetItem.
setText
(text)¶ - Parameters
text – str
-
PySide6.QtWidgets.QTableWidgetItem.
setTextAlignment
(alignment)¶ - Parameters
alignment – int
-
PySide6.QtWidgets.QTableWidgetItem.
setToolTip
(toolTip)¶ - Parameters
toolTip – str
-
PySide6.QtWidgets.QTableWidgetItem.
setWhatsThis
(whatsThis)¶ - Parameters
whatsThis – str
-
PySide6.QtWidgets.QTableWidgetItem.
sizeHint
()¶ - Return type
-
PySide6.QtWidgets.QTableWidgetItem.
statusTip
()¶ - Return type
str
-
PySide6.QtWidgets.QTableWidgetItem.
tableWidget
()¶ - Return type
-
PySide6.QtWidgets.QTableWidgetItem.
text
()¶ - Return type
str
-
PySide6.QtWidgets.QTableWidgetItem.
textAlignment
()¶ - Return type
int
-
PySide6.QtWidgets.QTableWidgetItem.
toolTip
()¶ - Return type
str
-
PySide6.QtWidgets.QTableWidgetItem.
type
()¶ - Return type
int
-
PySide6.QtWidgets.QTableWidgetItem.
whatsThis
()¶ - Return type
str
-
PySide6.QtWidgets.QTableWidgetItem.
write
(out)¶ - Parameters
Writes the item to stream out
.
See also
© 2021 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.