Re: TreeView update



On Thu, 2008-06-05 at 15:15 +0800, Dinh Khac Thanh wrote:
> Hi all,
> 
> I created a TreeView and a ListStore TreeModel in a Maemo application.
> The model is updated dynamically with data from an input file. 
> 
> Gtk::TreeView m_TreeView;
> Glib::RefPtr<Gtk::ListStore> m_refTreeModel;
> To add row:
> Gtk::TreeModel::Row row = *(m_refTreeModel->append());
> 
> To delete row: 
> typedef Gtk::TreeModel::Children type_children;
> type_children children = m_refTreeModel->children();
> type_children::iterator iter = children.begin();
> and
> iter=m_refTreeModel->erase(iter); //in a while loop

I think the problem might be that you're doing this in a while loop.  If
you erase an iter, the iters that come after that become invalidated, so
when you move on to the next iter and try to delete it, it doesn't work
as expected.  If you want to remove all nodes, you could just use
Gtk::ListStore::clear().  Alternately, you might have better success if
you remove them from the end first.  Gtk::TreeRowReference might also be
helpful since it doesn't get invalidated when a different iter is
deleted.

-- 
Jonner



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