« Return to Thread: Custom cell_data_func for treeviewcolumn warnings.

Custom cell_data_func for treeviewcolumn warnings.

by Germán Diago :: Rate this Message:

Reply to Author | View in Thread

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?
And if it is, is there any workaround to not require my class to
inherit from Glib::Object without
splitting MisCols class into separate fields. Thanks in advance.



struct MiClase {
        std::string a;
public:
        MiClase() {}
        MiClase(std::string aa) : a(aa) {}
};

struct MisCols : TreeModelColumnRecord {
        Gtk::TreeModelColumn<MiClase *> entero_;
public:

        MisCols() {
                add(entero_);
        }
};

void funcCol(CellRenderer * r, const Gtk::TreeModel::iterator& iter)
{
        CellRendererText * re = (CellRendererText *)r;
        Gtk::TreeModelColumn<MiClase *> col;
        re->property_text() = (iter->get_value(col)->a);
       
// re->property_text() = iter->get_value(col)->a;
}


int main(int argc, char * argv[]) {
        Main m(argc, argv);
        TreeView tv;
        Window w;
        MisCols cols;
       
        vector<MiClase> mc = {MiClase("hola"), MiClase("adios") };
               
        auto l = ListStore::create(cols);
        tv.set_model(l);

        auto row = *l->append();

        row[cols.entero_] = &mc[0];
       
        //row = *l->append();
        //row[cols.entero_] = &mc[1];
       
        TreeViewColumn viewcol("MiClase", cols.entero_);
        viewcol.set_cell_data_func(*viewcol.get_first_cell_renderer(), &funcCol);
               
        tv.append_column(viewcol);
       
       
       
        w.add(tv);
        w.show_all();
        Main::run(w);
}
_______________________________________________
gtkmm-list mailing list
gtkmm-list@...
http://mail.gnome.org/mailman/listinfo/gtkmm-list

 « Return to Thread: Custom cell_data_func for treeviewcolumn warnings.