Re: Is it possible to store pointers in Gtk::Liststore?



Am Montag, den 22.06.2009, 23:32 +0200 schrieb Germán Diago:
> 
>         I've used a void* above because I was having trouble with
>         pointers to
>         complex objects, but I think that was due to having a static
>         DLF_ModelColumns instance instead of instantiating it when
>         needed. It
>         should be OK to include a pointer to anything you want.

It can be static, as long as a it isn't instantiated before Gtk::Main.
What I usually do is to have a function which simply returns a reference
to a static variable defined inside the function body.

> I don't know why, but I think my problem was similar. Now storing a
> pointer
> works for me. Then I just had to implement my own cell_data_func and
> done.
> Thank you very much. It helped.

Yes, it should just work.  There is a partial specialization for pointer
types which takes care of that.

On a side note, you might want to use a smart pointer instead, or the
memory management will get hairy.  But I don't know your circumstances,
so maybe this doesn't apply.

--Daniel




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