Re: weird behavior with TreeModel



Thanks very much for the clear explanations.  It all makes sense now.

Nalin Singal wrote:
Sorry for breaking up the reply.

Regarding the reorderable columns. When you do
menuColumns.id.set_reorderable(), you are trying to
set the column in the treeModel as reoderable. But
actually the column in the treeView is the one which
should be reorderable. Remember there are two
different sets of columns - one in the treemodel and
one in the treeview which are backed up by the
treemodel columns. So the columns in the treeview are
the ones which can be reordered and not the ones in
the treemodel because reordering is just a view thing.
So as you are doing the for loop, get the column you
want to set as reorderable from the treeview and call
set_reorderable on it.

Hope this helps :)

-Nalin


--- John Taber <jtaber johntaber net> wrote:


Has anyone else had problems with TreeModel?
1) If I try to append rows after using
TreeModel.clear(), it segfaults.
2) If I try to define a column as reorderable - it
does not compile but if I put it in a loop thru all the columns it
compiles okay.
3) I'm getting weird behavior when using a table
refresh function (setListToDisplay) - sometimes the view does not load the data, some times I get a glibmm memory error.

I'm running gtkmm 2.6.1 with gtk 2.6.4 with gcc
3.3.5 on debian sid

Here's excerpt of what I've been using - anything
wrong in what I'm doing?

in .h file:
    virtual void menuTreeOnClicked(const
Gtk::TreeModel::Path& path,
        Gtk::TreeViewColumn* column);
    //------ menu tree ----------
    class ModelColumns : public
Gtk::TreeModel::ColumnRecord {
    public:
        ModelColumns() {
            add(id);
            add(name);
        }
        Gtk::TreeModelColumn<int>id;
        Gtk::TreeModelColumn<std::string>name;
    };
    ModelColumns menuColumns;
    Gtk::ScrolledWindow menuWindow;
    Gtk::TreeView menuTreeView;
    Glib::RefPtr<Gtk::ListStore> menuTreeModel;

in .cpp file
//---------- menu tree -------------------------
    menuTreeModel =
Gtk::ListStore::create(menuColumns);
    menuTreeView.set_model(menuTreeModel);
    //Gtk::TreeModel::Row row =
*(menuTreeModel->append());
    //row[menuColumns.id] = 0;
    //row[menuColumns.name] = "";
    menuTreeView.append_column("ID",
menuColumns.id);
    //(menuColumns.id).set_reorderable();
    menuTreeView.append_column("Name",
menuColumns.name);
    for(int i=0;i<2;i++) {
        Gtk::TreeView::Column* mColumn =
menuTreeView.get_column(i);
        mColumn->set_reorderable();
    }
    menuWindow.set_policy(Gtk::POLICY_AUTOMATIC,
Gtk::POLICY_AUTOMATIC);
    menuWindow.add(menuTreeView);

menuTreeView.signal_row_activated().connect(sigc::mem_fun(*this,

          &LanduseListDialog::menuTreeOnClicked) );
.....
void


LanduseListDialog::setListToDisplay(std::vector<Data*>data)

{
    if (data.empty()) {return;}
    //menuTreeModel.clear();
    Gtk::TreeModel::Row row;
    for (uint i=0;i<data.size();i++) {
        row = *(menuTreeModel->append());
        row[menuColumns.id] = data[i]->getid();
        row[menuColumns.name] = data[i]->getname();
    }
}


_______________________________________________
gtkmm-list mailing list
gtkmm-list gnome org
http://mail.gnome.org/mailman/listinfo/gtkmm-list





		
__________________________________________________________
How much free photo storage do you get? Store your friends 'n family snaps for FREE with Yahoo! Photos http://in.photos.yahoo.com





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