Re: Custom cell_data_func for treeviewcolumn warnings.



Am Sonntag, den 21.06.2009, 23:44 +0200 schrieb Germán Diago:
> Hello. I'm having problems with this code. The problem is that I get a
> lot of warnings
> when I try to insert rows in my TreeModel from the main function.
> My TreeColumnRecord has a pointer type, but it's not derived from
> Glib::Object. Is this the problem?

No.

> 	Gtk::TreeModelColumn<MiClase *> col;
> 	re->property_text() = (iter->get_value(col)->a);

This is the problem.  That TreeModelColumn is not assigned to any tree
model column.  You need to use a direct reference to the TreeModelColumn
instance you added to the TreeModelColumnRecord.

For background, a TreeModelColumn stores two things: The C GType that
corresponds to the C++ template argument, and the model column index.
The model column index is assigned by the add() method, starting from
zero and incremented by one with each add() call.

The idea behind the TreeModelColumn and TreeModelColumnRecord classes is
to tie the dynamic type information of the C API and the static type
information of the C++ API together.  This makes it possible to have all
the flexibility offered by the GtkTreeModel API without sacrificing
compile-time type-safety.

> //	re->property_text() = iter->get_value(col)->a;

Hm, get_value() is sort of half-internal API.  It is preferable to write

    MiClase* value = (*iter)[columns.entero];
    re->property_text() = value->a;

instead.

--Daniel




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