qtreewidgetitem - item contained in a QTreeWidget
Name
qtreewidgetitem — item contained in a QTreeWidget
Syntax
qtreewidgetitem itemnames type
qtreewidgetitem treewidget itemnames type
qtreewidgetitem parentitem itemnames type
Description
The qtreewidgetitem command creates a QTreeWidgetItem object. These are used to populate a qtreewidget in a hierarchical manner. The qtreewidgetitem command returns the newly created item object.
Items may have text and/or icons. These appear in columns created with the qsetheaderlabels command. Text and icons are set using the qsettext and qicon commands.
Tree widget items are arranged hierarchically in a tree-like structure. An item may play the role of parent, child or sibling as illustrated in Simple QTreeWidgetItem.
No items can be added to a treewidget before the header columns are in place.
Arguments
itemnames
A Tcl list containing item names, one for each column.
type
An integer denoting the class to which this item will belong. This is a freely chosen number that divides conceptually similar items into groups. You could choose to have all items containing JPG images have the same type identifier. Later you can assign a rightclick menu to this class using the qsetmenu command.
qtreewidget
The tree widget in which this item will created. The item will be a top level item.
qtreewidgetitem
Parent item for the item to be created.
Examples
Ex.1: Simple QTreeWidgetItem
set w [qwidget ] qsetwindowtitle "QTreeWidget" set layout [qvboxlayout $w] # Create tree set tree [qtreewidget ] qaddwidget $layout $tree qsetheaderlabels $tree { Name Type } # Icon file set folder_file [file join $Geocap::geocapdir icons fileopen.xpm] # Create icons set folder_icon [qicon $folder_file] set item [qtreewidgetitem $tree { "My File" JPG } 1 ] set item [qtreewidgetitem $tree { "Folder" "" } 2 ] qseticon $item 0 $folder_icon set item [qtreewidgetitem $item { "Letter" TXT } 1 ] qshow $w
See qtreewidget for more advanced use of the tree widget.