Re: [gtkmm] it´s driving me mad ... (replacing contents of VBox)



Am 2004.02.15 16:48 schrieb(en) Andreas B. Thun:
Hi!

I have a problem here I just cannot solve:
VBox myBox is containing some widgets1..3 I show
first.
Later in my program (windows stays the same), I build
a new VBox to display widgets4..5 instead, but the widgets1..3
stay displayed!

Can somebody throw light on this?



.h:
Gtk::VBox *myBox; // Pointer to VBox I want to display

.cpp:

// 1st object of VBox holds widgets1..3 and shows them -> fine
myBox = Gtk::manage(new Gtk::VBox());
myBox->pack_start(widget1);
myBox->pack_start(widget2);
myBox->pack_start(widget3);
myBox.show();

(Note that myBox.show() doesn't make widget1..3 visible. Use
show_all() instead.)


...

// Assigning the new VBox to the Pointer myBox
// but the new widgets are not displayed!!
myBox = Gtk::manage(new Gtk::VBox());

You assign a pointer, but you don't change the widget tree.
You must first remove the old VBox and then add the new one
to the parent widget. To remove and destroy a widget use
delete. (I'm not sure whether this works with Gtk::manage() -
you'll have to try.)

Regards,

 Martin


myBox->pack_start(widget4);
myBox->pack_start(widget5);
myBox->pack_start(widget6);
myBox.show();


TIA,
Andi

_______________________________________________
gtkmm-list mailing list
gtkmm-list gnome org
http://mail.gnome.org/mailman/listinfo/gtkmm-list



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