Re: Treeview with editable checkboxes besides items?



smso graduate hku hk wrote:
The signature of the function  "add_attribute()" in:

pColumn->add_attribute(pActive->property_active (), m_columns.active);

does not match with those in the api.
API Reference:
http://www.gtkmm.org/docs/gtkmm-2.4/docs/reference/html/classGtk_1_1TreeViewColumn.html

"pActive->property_active ()" should return either "true" or "false"

I think you are wrong here. It does match with the signature of the second add_attribute variant:

void Gtk::TreeViewColumn::add_attribute (
   const Glib::PropertyProxy_Base& property,
   const TreeModelColumnBase& column) 	

I have placed Gtk::CellRendererToggle and Gtk::CellRendererText in the same
Gtk::TreeViewColumn
The toggle renderer can be checked or unchecked.
Here are some codes that I used:

	renderer_toggle.property_activatable() = true;
	treeview_col.set_title("Selected");
	treeview_col.pack_start(renderer_toggle, true);
	treeview_col.add_attribute(renderer_toggle, "active", 0);

You pack only one cellrenderer in the column and use one of the other "add_attribute" functions, but for the rest the code is the same as mine (I checked and your variant has the same problem, even with only one cellrenderer). You are right when you say the toggle renderer can be checked or unchecked (by changing the boolean value in the underlying model through code). But I can't modify that value through the user interface!

If I simply do:

m_treeview->append_column_editable ("Active", m_columns.active);
m_treeview->append_column ("Name", m_columns.name);

the values can be changed through the user interface as expected. But this creates two separate columns (see screenshot [1]), but I only want one (see screenshot [2]).

[1] http://users.telenet.be/sacn/tmp/treeview_2.png
[2] http://users.telenet.be/sacn/tmp/treeview_3.png

By the way,
I try to use `property_editable' but the compiler complains with:
`class Gtk::CellRendererToggle' has no member named `property_editable'

CellRendererToggle does not have a 'property_editable'. That property is for use with CellRendererText.

Please make sure you are using the most recent version of Gtkmm.

I'm using packages from Ubuntu Feisty:

$pkg-config --modversion gtkmm-2.4 gtk+-2.0
2.10.8
2.10.11




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