Exempel

Några TreeView-exempel visas här. Det finns mer exempel i treeview-katalogen i gtkmm-documentations exempel.

Om varken ListStore eller TreeStore är lämplig för ditt program kan du titta på exemplet anpassad TreeModel. Det visar dig hur du kan göra din egen implementation av TreeModel-gränssnittet.

ListStore

Detta exempel har en Gtk::TreeView-komponent med en Gtk::ListStore-modell.

TreeView - ListStore

Källkod

TreeStore

Detta exempel är väldigt likt ListStore-exemplet, men använder en Gtk::TreeStore-modell i stället, och lägger till underordnade till raderna.

TreeView - TreeStore

Källkod

Redigerbara celler

Detta exempel är identiskt med ListStore-exemplet, men använder TreeView::append_column_editable() i stället för TreeView::append_column().

TreeView - Redigerbara celler

Källkod

Dra och släpp

This example is much like the TreeStore example, but has 2 extra columns to indicate whether the row can be dragged, and whether it can receive drag-and-dropped rows. It uses a derived Gtk::TreeStore which overrides the virtual functions as described in the TreeView Drag and Drop section.

TreeView - Dra och släpp

Källkod

Poppuppsnabbvalsmeny

This example is much like the ListStore example, but derives a custom TreeView to encapsulate the tree model code and popup menu code in our derived class. See the TreeView Popup Context Menu section.

TreeView - Poppuppsnabbvalsmeny

Källkod