Skip to content

PythonQt.Qt.QTreeWidgetItem

QTreeWidgetItem

PythonQtInstanceWrapper object

Native bases: PythonQtInstanceWrapper

Supplemental documentation: Qt 5 reference:

Detailed Description

Tree widget items are used to hold rows of information for tree widgets. Rows usually contain several columns of data, each of which can contain a text label and an icon.

The QTreeWidgetItem class is a convenience class that replaces the QListViewItem class in Qt 3. It provides an item for use with the QTreeWidget class.

Items are usually constructed with a parent that is either a QTreeWidget (for top-level items) or a QTreeWidgetItem (for items on lower levels of the tree). For example, the following code constructs a top-level item to represent cities of the world, and adds a entry for Oslo as a child item:

    QTreeWidgetItem *cities = new QTreeWidgetItem(treeWidget);
    cities->setText(0, tr("Cities"));
    QTreeWidgetItem *osloItem = new QTreeWidgetItem(cities);
    osloItem->setText(0, tr("Oslo"));
    osloItem->setText(1, tr("Yes"));

Items can be added in a particular order by specifying the item they follow when they are constructed:

    QTreeWidgetItem *planets = new QTreeWidgetItem(treeWidget, cities);
    planets->setText(0, tr("Planets"));

Each column in an 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 column can be rendered with its own font and brush. These are specified with the setFont() and setForeground() functions, and read with font() and foreground().

The main difference between top-level items and those in lower levels of the tree is that a top-level item has no parent(). This information can be used to tell the difference between items, and is useful to know when inserting and removing items from the tree. Children of an item can be removed with takeChild() and inserted at a given index in the list of children with the insertChild() function.

By default, items are enabled, selectable, checkable, and can be the source of a drag and drop operation. 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 QTreeWidgetItem 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/qtreewidgetitem.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
ChildIndicatorPolicy attribute type Convert a number or string to an integer, or return 0 if no arguments are given. (shared captured text)
DontShowIndicator attribute Any (shared captured text)
DontShowIndicatorWhenChildless attribute Any (shared captured text)
ItemType attribute type Convert a number or string to an integer, or return 0 if no arguments are given. (shared captured text)
ShowIndicator attribute Any (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)
addChild function (self, child: Any) -> None Appends the child item to the list of children. (shared captured text)
addChildren function (self, children: Any) -> None Appends the given list of children to the item. (shared captured text)
background function (self, column: int) -> Any X.background(column) -> PythonQt.QtGui.QBrush (shared captured text)
checkState function (self, column: int) -> Any Returns the check state of the label in the given column. (shared captured text)
child function (self, index: int) -> Any X.child(index) -> PythonQt.QtGui.QTreeWidgetItem (shared captured text)
childCount function (self) -> int X.childCount() -> int (shared captured text)
childIndicatorPolicy function (self) -> Any Returns the item indicator policy. (shared captured text)
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.QTreeWidgetItem (shared captured text)
columnCount function (self) -> int X.columnCount() -> int (shared captured text)
data function (self, column: int, role: int) -> Any X.data(column, role) -> object (shared captured text)
delete function (self, *args: Any, **kwargs: Any) -> Any Deletes the C++ object (at your own risk, my friend!) (shared captured text)
emitDataChanged function (self) -> None Causes the model associated with this item to emit a [dataChanged](https://doc.qt.io/archives/qt-5.15/qabstractitemmodel.html#dataChanged)() signal for this item. (shared captured text)
flags function (self) -> Any Returns the flags used to describe the item. (shared captured text)
font function (self, column: int) -> Any X.font(column) -> PythonQt.QtGui.QFont (shared captured text)
foreground function (self, column: int) -> Any X.foreground(column) -> PythonQt.QtGui.QBrush (shared captured text)
help function (self, *args: Any, **kwargs: Any) -> Any Shows the help of available methods for this class (shared captured text)
icon function (self, column: int) -> Any X.icon(column) -> PythonQt.QtGui.QIcon (shared captured text)
indexOfChild function (self, child: Any) -> int X.indexOfChild(child) -> int (shared captured text)
inherits function (self, *args: Any, **kwargs: Any) -> Any Returns if the class inherits or is of given type name (shared captured text)
insertChild function (self, index: int, child: Any) -> None X.insertChild(index, child) (shared captured text)
insertChildren function (self, index: int, children: Any) -> None X.insertChildren(index, children) (shared captured text)
isDisabled function (self) -> bool X.isDisabled() -> bool (shared captured text)
isExpanded function (self) -> bool X.isExpanded() -> bool (shared captured text)
isFirstColumnSpanned function (self) -> bool X.isFirstColumnSpanned() -> bool (shared captured text)
isHidden function (self) -> bool X.isHidden() -> bool (shared captured text)
isSelected function (self) -> bool X.isSelected() -> bool (shared captured text)
parent function (self) -> Any X.parent() -> PythonQt.QtGui.QTreeWidgetItem (shared captured text)
read function (self, *args: Any, **kwargs: Any) -> None Reads the item from stream in. (shared captured text)
readFrom function (self, *args: Any, **kwargs: Any) -> Any (shared captured text)
removeChild function (self, child: Any) -> None Removes the given item indicated by child. (shared captured text)
setBackground function (self, column: int, brush: Any) -> None X.setBackground(column, brush) (shared captured text)
setCheckState function (self, column: int, state: Any) -> None X.setCheckState(column, state) (shared captured text)
setChildIndicatorPolicy function (self, policy: Any) -> None Sets the item indicator policy. (shared captured text)
setData function (self, column: int, role: int, value: Any) -> None X.setData(column, role, value) (shared captured text)
setDisabled function (self, disabled: bool) -> None Disables the item if disabled is true; otherwise enables the item. (shared captured text)
setExpanded function (self, expand: bool) -> None Expands the item if expand is true, otherwise collapses the item. (shared captured text)
setFirstColumnSpanned function (self, span: bool) -> None Sets the first section to span all columns if span is true; otherwise all item sections are shown. (shared captured text)
setFlags function (self, arg0: flags) -> None Sets the flags for the item to the given flags. (shared captured text)
setFont function (self, column: int, font: Any) -> None X.setFont(column, font) (shared captured text)
setForeground function (self, column: int, brush: Any) -> None X.setForeground(column, brush) (shared captured text)
setHidden function (self, hide: bool) -> None Hides the item if hide is true, otherwise shows the item. (shared captured text)
setIcon function (self, column: int, icon: Any) -> None X.setIcon(column, icon) (shared captured text)
setSelected function (self, select: bool) -> None Sets the selected state of the item to select. (shared captured text)
setSizeHint function (self, column: int, size: Any) -> None X.setSizeHint(column, size) (shared captured text)
setStatusTip function (self, column: int, statusTip: str) -> None X.setStatusTip(column, statusTip) (shared captured text)
setText function (self, column: int, text: str) -> None X.setText(column, text) (shared captured text)
setTextAlignment function (self, column: int, alignment: int) -> None X.setTextAlignment(column, alignment) (shared captured text)
setToolTip function (self, column: int, toolTip: str) -> None X.setToolTip(column, toolTip) (shared captured text)
setWhatsThis function (self, column: int, whatsThis: str) -> None X.setWhatsThis(column, whatsThis) (shared captured text)
sizeHint function (self, column: int) -> Any X.sizeHint(column) -> PythonQt.QtCore.QSize (shared captured text)
sortChildren function (self, column: int, order: Any) -> None X.sortChildren(column, order) (shared captured text)
statusTip function (self, column: int) -> str X.statusTip(column) -> str (shared captured text)
takeChild function (self, index: int) -> Any X.takeChild(index) -> PythonQt.QtGui.QTreeWidgetItem (shared captured text)
takeChildren function (self) -> tuple X.takeChildren() -> tuple (shared captured text)
text function (self, column: int) -> str X.text(column) -> str (shared captured text)
textAlignment function (self, column: int) -> int X.textAlignment(column) -> int (shared captured text)
toolTip function (self, column: int) -> str X.toolTip(column) -> str (shared captured text)
treeWidget function (self) -> Any X.treeWidget() -> PythonQt.QtGui.QTreeWidget (shared captured text)
type function (self) -> int X.type() -> int (shared captured text)
whatsThis function (self, column: int) -> str X.whatsThis(column) -> str (shared captured text)
write function (self, out: Any) -> None Writes the item to stream out. (shared captured text)
writeTo function (self, out: Any) -> Any (shared captured text)