QgsTreeWidgetItem class
QTreeWidgetItem subclass with custom handling for item sorting.
Contents
QgsTreeWidgetItem allows for items to be sorted using a specified user role, and also correctly handles sorting numeric or mixed text and numeric values.
Derived classes
- class QgsTreeWidgetItemObject
- Custom QgsTreeWidgetItem with extra signals when item is edited.
Constructors, destructors, conversion operators
- QgsTreeWidgetItem(QTreeWidget* view, int type = Type) explicit
- Constructor for QgsTreeWidgetItem.
- QgsTreeWidgetItem(int type = Type) explicit
- Constructor for QgsTreeWidgetItem.
- QgsTreeWidgetItem(const QStringList& strings, int type = Type)
- Constructor for QgsTreeWidgetItem.
- QgsTreeWidgetItem(QTreeWidget* view, const QStringList& strings, int type = Type)
- Constructor for QgsTreeWidgetItem.
- QgsTreeWidgetItem(QTreeWidget* view, QTreeWidgetItem* after, int type = Type)
- Constructor for QgsTreeWidgetItem.
- QgsTreeWidgetItem(QTreeWidgetItem* parent, int type = Type) explicit
- Constructor for QgsTreeWidgetItem.
- QgsTreeWidgetItem(QTreeWidgetItem* parent, const QStringList& strings, int type = Type)
- Constructor for QgsTreeWidgetItem.
- QgsTreeWidgetItem(QTreeWidgetItem* parent, QTreeWidgetItem* after, int type = Type)
- Constructor for QgsTreeWidgetItem.
Public functions
- auto alwaysOnTopPriority() const -> int
- Returns the item's priority when it is set to show always on top.
- auto operator<(const QTreeWidgetItem& other) const -> bool override
- Returns true if this item should appear before another item when sorting a list of items.
- auto operator>=(const QTreeWidgetItem& other) const -> bool
- Returns true if this item should appear after another item when sorting a list of items.
- void setAlwaysOnTopPriority(int priority)
- 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.
- void setSortData(int column, const QVariant& value)
- Sets the custom sort data for a specified column.
- auto sortData(int column) const -> QVariant
- Returns the custom sort data for a specified column.
Function documentation
QgsTreeWidgetItem:: QgsTreeWidgetItem(QTreeWidget* view,
int type = Type) explicit
Constructor for QgsTreeWidgetItem.
| Parameters | |
|---|---|
| view | parent QTreeWidget view |
| type | item type |
QgsTreeWidgetItem:: QgsTreeWidgetItem(int type = Type) explicit
Constructor for QgsTreeWidgetItem.
| Parameters | |
|---|---|
| type | item type |
QgsTreeWidgetItem:: QgsTreeWidgetItem(const QStringList& strings,
int type = Type)
Constructor for QgsTreeWidgetItem.
| Parameters | |
|---|---|
| strings | list of strings containing text for each column in the item |
| type | item type |
QgsTreeWidgetItem:: QgsTreeWidgetItem(QTreeWidget* view,
const QStringList& strings,
int type = 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:: QgsTreeWidgetItem(QTreeWidget* view,
QTreeWidgetItem* after,
int type = Type)
Constructor for QgsTreeWidgetItem.
| Parameters | |
|---|---|
| view | parent QTreeWidget view |
| after | QTreeWidgetItem to place insert item after in the view |
| type | item type |
QgsTreeWidgetItem:: QgsTreeWidgetItem(QTreeWidgetItem* parent,
int type = Type) explicit
Constructor for QgsTreeWidgetItem.
| Parameters | |
|---|---|
| parent | QTreeWidgetItem item |
| type | item type |
QgsTreeWidgetItem:: QgsTreeWidgetItem(QTreeWidgetItem* parent,
const QStringList& strings,
int type = Type)
Constructor for QgsTreeWidgetItem.
| Parameters | |
|---|---|
| parent | QTreeWidgetItem item |
| strings | list of strings containing text for each column in the item |
| type | item type |
QgsTreeWidgetItem:: QgsTreeWidgetItem(QTreeWidgetItem* parent,
QTreeWidgetItem* after,
int type = Type)
Constructor for QgsTreeWidgetItem.
| Parameters | |
|---|---|
| parent | QTreeWidgetItem item |
| after | QTreeWidgetItem to place insert item after in the view |
| type | item type |
int QgsTreeWidgetItem:: alwaysOnTopPriority() const
Returns the item's priority when it is set to show always on top.
| Returns | priority, or -1 if item is not set to show always on top |
|---|
Items with a lower priority will be placed above items with a higher priority.
void QgsTreeWidgetItem:: setAlwaysOnTopPriority(int priority)
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. |
void QgsTreeWidgetItem:: setSortData(int column,
const QVariant& value)
Sets the custom sort data for a specified column.
| Parameters | |
|---|---|
| column | column index |
| value | sort value |
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.
QVariant QgsTreeWidgetItem:: sortData(int column) const
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.