Skip to content

Tree Items

Custom tree widget items with enhanced functionality.

Preview

FXTreeItems

FXSortedTreeWidgetItem

Bases: QTreeWidgetItem

Custom QTreeWidgetItem that provides natural sorting for strings containing numbers. This is useful for sorting items like version numbers or other strings where numeric parts should be ordered numerically.

For example, this class will sort the following strings in the correct human-friendly order:

  • "something1"
  • "something9"
  • "something17"
  • "something25"

Instead of the default sorting order:

  • "something1"
  • "something17"
  • "something25"
  • "something9"

Methods:

Name Description
__lt__

Override the less-than operator to provide a custom sorting logic.

__lt__

__lt__(other: FXSortedTreeWidgetItem) -> bool

Override the less-than operator to provide a custom sorting logic.

Parameters:

Name Type Description Default

other

FXSortedTreeWidgetItem

Another instance of FXSortedTreeWidgetItem to compare with.

required

Returns:

Type Description
bool

True if the current item is less than the other item according to

bool

the natural sort order, False otherwise.