[Xfc-dev] A little help

Benedikt Meurer benedikt.meurer at unix-ag.uni-siegen.de
Tue May 2 23:56:38 CEST 2006


Ricardo M wrote:
> Have a nice day
> I've tried to writte a program with the treeview
> class, but for some reason i don't understand, the
> program abort in runtime, here's my code:
> 
> std::vector<GType> types;
> for (int i=0; i<nCols; i++) {
>   types.push_back(G_TYPE_STRING);
> }
> 
> Gtk::ListStore *model = new
> Gtk::ListStore(nCols,types);
> ...
> 
> But when i compile the result is:
> 
> ClassGrid.cc: In constructor
> `classGrid::classGrid(Xfc::String)':
> ClassGrid.cc:49: warning: cannot pass objects of
> non-POD type `class 
>    std::vector<GType, std::allocator<GType> >' through
> `...'; call will abort 
>    at runtime

The constructor is

 ListStore (int n_columns, const GType *types)

so you cannot pass an STL vector for the second argument, instead use:

enum
{
  COLUMN_1,
  COLUMN_2,
  N_COLUMNS,
};

//...

const GType types[N_COLUMNS] = {
  G_TYPE_STRING,
  G_TYPE_STRING
};

Gtk::ListStore *model = new Gtk::ListStore(N_COLUMNS, types);

where COLUMN_1, COLUMN_2, etc. is just an example. The tutorial is a bit
outdated here unfortunately.

> Any idea?
> Thanks in advance

HTH,
Benedikt



More information about the Xfc-dev mailing list