ListStore usage question



Hi all,

I'm tring to use a TreeView  and I have some problem updating the list

0) I create ColumnRecord

class TreeCashColumns : public Gtk::TreeModel::ColumnRecord {
public:
	Gtk::TreeModelColumn<Glib::ustring> m_Col1;

	TreeCashColumns() {
	    add(m_Col1);
	}
}


//Member Variable 
TreeCashColumns m_Columns;


1) I create the ListStore model 

m_TreeModel = Gtk::ListStore::create(m_Columns);

2) I Add columns to the view
TreeViewCashes->append_column("Col1",m_Columns.m_Col1);


3) I add rows

Gtk::TreeModel::Row row = *( m_TreeModel ->append());	
row[m_Columns.m_Col1] = "Col1";

4) I set the model

TreeViewCashes->set_model( m_Model);


I don't understand why the function TreeView::set_model deferences the model
pointer (I see source code after a segfault), so that after such call
m_Model is no more valid.

If I need to refresh the rows, I cannot use m_Model because it was
deferenced, and I cannot find a way to get ListStore from TreeView. 
I solved creating a new model but I don't think this is a good solution.

TreeView::get_model return only the base class TreeModel that don't have
clear() method to clear all rows.

Where am I wrong?

Thanks in advance.

Marco








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