TreeView with a ComboBox



Hi,

I want to have a grid of data displayed in worksheet-like format. Some
of the columns have a finite number of values, so I want to use a
combobox. It's been a bit of a challenge to get the program to compile
(but again, I've just started using Gtkmm). Now it crashes when I
attempt to run it. 
Two questions:
- Should I use a cell CellRendererCombo? I might have up to about a
thousand rows. Is that going to affect the speed?
- I get a segmentation fault when trying to set_active on this row. What
could I be missing?

Glib::RefPtr<Gtk::ComboBox>((*iter)[m_Columns.m_readwrite])->set_active(0);
Program received signal SIGSEGV, Segmentation fault.
0xb7e97e78 in Gtk::ComboBox::set_active ()
from /usr/lib/libgtkmm-2.4.so.1

 When I'm creating the tree view I do this for that column:

	pRenderer = Gtk::manage(new Gtk::CellRendererCombo());
	Glib::RefPtr<Gtk::TreeModel> pModel(new CReadWriteList());
	pRenderer->property_model().set_value( pModel );
	m_TreeView.append_column("RW", *pRenderer);

with the following definition from the CReadWriteList:

class CReadWriteCols : public Gtk::TreeModelColumnRecord
{
public:
	CReadWriteCols() { add(m_column); }
	Gtk::TreeModelColumn<Glib::ustring> m_column;
};

class CReadWriteList: public Gtk::ListStore
{
public:
	CReadWriteList(){
		iterator i;
		set_column_types( m_Cols );
		i = append();
		i->set_value(m_Cols.m_column,Glib::ustring("Read SDO"));
		i = append();
		i->set_value(m_Cols.m_column,Glib::ustring("Write SDO"));
		i = append();
		i->set_value(m_Cols.m_column,Glib::ustring("Read PDO"));
		i = append();
		i->set_value(m_Cols.m_column,Glib::ustring("off"));
	}
	CReadWriteCols m_Cols;
};	




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