Gtk::Treeview columns size management



Hi,

I'm trying to manage the size of the columns of a treeview. While doing
it I found some properties which I would like to discuss and find some
conclusions.

As experiment  I heave created a derived class from the treeview,
containing all the models declared and managed inside.

class ActionList : public Gtk::TreeView
{
    ....
}

The first task was to give equal sizes to all columns of the treeview.
So I wanted to get the treeview width and divide it by the number of
columns.

ActionList::ActionList ()
{
    Glib::ListHandle<Gtk::TreeViewColumn*> columns_list = get_columns ();

    if (columns_list.size () != 0)
    {
        int treeview_width = get_width ();
        int column_width = get_width () / columns_list.size ();

        for (Glib::ListHandle<Gtk::TreeViewColumn*>::iterator iter =
columns_list.begin ();
               iter != columns_list.end ();
              ++iter)
        {
            (*iter)->set_resizable (true);
            (*iter)->set_fixed_width (200);
         }
    }
}


This failed and in debuggind I found that the treeview width was not
given in correctly. So I supposed that this was because the treeview was
not displayed while trying to extract the width values. For testing I
set a button which on clicking run the same code in a class method.
In this second experiment the width value was correct but it didn't
resize the columns.

I want to know two things.

1. Which methods must be used to resize the columns?

2. What signal should be catch to permit automatic resize of the
columns? That is, if I can't use the class constructor, which should I use?

Best regards
Pedro Sousa


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