weird behavior with TreeModel
- From: John Taber <jtaber johntaber net>
- To: gtkmm-list gnome org
- Subject: weird behavior with TreeModel
- Date: Wed, 22 Jun 2005 08:56:09 -0600
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();
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]