Class: QgsTreeWidgetItem

class qgis.gui.QgsTreeWidgetItem(view: QTreeWidget, type: int = QTreeWidgetItem.Type)

Bases: PyQt5.QtWidgets.QTreeWidgetItem

Constructor for QgsTreeWidgetItem

Parameters
  • view (QTreeWidget) – parent QTreeWidget view

  • type (int = QTreeWidgetItem.Type) – item type

QgsTreeWidgetItem(type: int = QTreeWidgetItem.Type) Constructor for QgsTreeWidgetItem

Parameters

type – item type

QgsTreeWidgetItem(strings: Iterable[str], type: int = QTreeWidgetItem.Type) Constructor for QgsTreeWidgetItem

Parameters
  • strings – list of strings containing text for each column in the item

  • type – item type

QgsTreeWidgetItem(view: QTreeWidget, strings: Iterable[str], type: int = QTreeWidgetItem.Type) Constructor for QgsTreeWidgetItem

Parameters
  • view – parent QTreeWidget view

  • strings – list of strings containing text for each column in the item

  • type – item type

QgsTreeWidgetItem(view: QTreeWidget, after: QTreeWidgetItem, type: int = QTreeWidgetItem.Type) Constructor for QgsTreeWidgetItem

Parameters
  • view – parent QTreeWidget view

  • after – QTreeWidgetItem to place insert item after in the view

  • type – item type

QgsTreeWidgetItem(parent: QTreeWidgetItem, type: int = QTreeWidgetItem.Type) Constructor for QgsTreeWidgetItem

Parameters
  • parent – QTreeWidgetItem item

  • type – item type

QgsTreeWidgetItem(parent: QTreeWidgetItem, strings: Iterable[str], type: int = QTreeWidgetItem.Type) Constructor for QgsTreeWidgetItem

Parameters
  • parent – QTreeWidgetItem item

  • strings – list of strings containing text for each column in the item

  • type – item type

QgsTreeWidgetItem(parent: QTreeWidgetItem, after: QTreeWidgetItem, type: int = QTreeWidgetItem.Type) Constructor for QgsTreeWidgetItem

Parameters
  • parent – QTreeWidgetItem item

  • after – QTreeWidgetItem to place insert item after in the view

  • type – item type

QgsTreeWidgetItem(QgsTreeWidgetItem)

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.

Methods

alwaysOnTopPriority

Returns the item’s priority when it is set to show always on top.

emitDataChanged

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.

setSortData

Sets the custom sort data for a specified column.

sortData

Returns the custom sort data for a specified column.

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.

Return type

int

Returns

priority, or -1 if item is not set to show always on top

emitDataChanged(self)
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 (int) – 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 (int) – column index

  • value (Any) – 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()

Parameters

column (int) –

Return type

Any