Re: Using a TreeStore with a ComboBox



On 6/21/07, Jef Driesen <jefdriesen hotmail com> wrote:
Using a treestore model with a combobox creates a nice dropdown list
with submenus. Inside each submenu, the parent item is shown with a
separator below to separate it from its children. I want to know how I
can hide this parent node, so I can only select leaf nodes (e.g items
without children).

The model contains places that can be are arranged by the user in an
arbitrary hierarchy, to group related places together (for instance by
continent and/or country). This is very similar how files (my places)
can be arranged into directories (my hierarchy). But when the user needs
to select a place with the combobox, it doesn't make sense to be able to
select an item that is not a place.

You could probably accomplish this fairly easily with TreeModelFilter
(http://gtkmm.org/docs/gtkmm-2.4/docs/reference/html/classGtk_1_1TreeModelFilter.html)
wrapping your existing treestore. You'd just need to provide a
function which checks whether a node has children or not, and pass
that function to TreeModelFilter::set_visible_func().  Hope that
helps.
--
jonner



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]