Re: adding widget to vbox created by glade



On Sun, 2 Dec 2007, Gezim Hoxha <gezimetc shaw ca> wrote :

So, now this code works:
      Gtk::VolumeButton *my1223 = new Gtk::VolumeButton;
      myvbox->pack_end(*my1223);
      my1223->show();

but this doesn't:
      Gtk::VolumeButton my1223;
      myvbox->pack_end(my1223);
      my1223.show();

and my question is, why doesn't this last code work?

Is this code in a function / method? Because if so the explanation is simple. The second form creates a _local_ _temporary_ Gtk::VolumeButton object and packs then shows it. And then the function / method terminates and all local objects are destroyed, including the widget.

The first form makes the widget on the heap and only destroys a pointer to it.
--
Rob Pearce                       http://www.bdt-home.demon.co.uk

The contents of this | Windows NT crashed.
message are purely   | I am the Blue Screen of Death.
my opinion. Don't    | No one hears your screams.
believe a word.      |


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