Subgroup: Tree

Class: QgsTreeWidgetItem

class qgis.gui.QgsTreeWidgetItem

Bases: PyQt5.QtWidgets.QTreeWidgetItem

QTreeWidgetItem subclass with custom handling for item sorting.

QgsTreeWidgetItem allows for items to be sorted using a specified user role, and also correctly handles sorting numeric or mixed text and numeric values.

New in version 3.0: Methods

addChild
addChildren
alwaysOnTopPriority Returns the item’s priority when it is set to show always on top.
background
checkState
child
childCount
childIndicatorPolicy
clone
columnCount
data
emitDataChanged
flags
font
foreground
icon
indexOfChild
insertChild
insertChildren
isDisabled
isExpanded
isFirstColumnSpanned
isHidden
isSelected
parent
read
removeChild
setAlwaysOnTopPriority Sets a the item to display always on top of other items in the widget, regardless of the sort column and sort or display value for the item.
setBackground
setCheckState
setChildIndicatorPolicy
setData
setDisabled
setExpanded
setFirstColumnSpanned
setFlags
setFont
setForeground
setHidden
setIcon
setSelected
setSizeHint
setSortData Sets the custom sort data for a specified column.
setStatusTip
setText
setTextAlignment
setToolTip
setWhatsThis
sizeHint
sortChildren
sortData Returns the custom sort data for a specified column.
statusTip
takeChild
takeChildren
text
textAlignment
toolTip
treeWidget
type
whatsThis
write

Attributes

DontShowIndicator
DontShowIndicatorWhenChildless
ShowIndicator
Type
UserType
alwaysOnTopPriority(self) → int

Returns the item’s priority when it is set to show always on top. Items with a lower priority will be placed above items with a higher priority.

Returns:priority, or -1 if item is not set to show always on top
emitDataChanged()
setAlwaysOnTopPriority(self, priority: int)

Sets a the item to display always on top of other items in the widget, regardless of the sort column and sort or display value for the item.

Parameters:priority – priority for sorting always on top items. Items with a lower priority will

be placed above items with a higher priority.

setSortData(self, column: int, value: Any)

Sets the custom sort data for a specified column. If set, this value will be used when sorting the item instead of the item’s display text. If not set, the item’s display text will be used when sorting.

Parameters:
  • column – column index
  • value – sort value

See also

sortData()

sortData(self, column: int) → Any

Returns the custom sort data for a specified column. If set, this value will be used when sorting the item instead of the item’s display text. If not set, the item’s display text will be used when sorting.

See also

setSortData()