Re: [gtkmm] adding a widget to a container



On Mon, May 03, 2004 at 04:19:47PM +0200, cedric wrote:
> Gtk::HBox a;    a.add(toolbarmod);
> //it works, normal

Yes, you've got an HBox and are using it.
 
> Gtk::HBox *b;    b->add(toolbarmod);
> // provoques a seg fault !?!?!

You have a POINTER to an HBox, but no HBox to actually point to, so when
you try to use it, BANG!

> Gtk::HBox *c;    (*c).add(toolbarmod);
> // provoques a seg fault !?!?!

As before.
Try Gtk::HBox *b = new Gtk::HBox; if you really want to allocate the
HBox on the heap (but wouldn't you rather use a class member?).
(But remember to use manage() or delete it yourself.)

~Ainsley



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