Re: help on array of widgets

It is the exact opposite ! :o)

std::vector<Gtk::Button*> buttons;
buttons.push_back(Gtk::manage(new Gtk::Button("but")));
vbox.pack_start(*buttons.back(), …

Calling Gtk::manage(widget_pointer) will cause the widget to be freed when its parent is destroyed.

Glib::RefPtr is generally not to be used when the API does not force you to use it.


On 27/07/11 13:21, Mj Mendoza IV wrote:
 > If you are looking for a way to store your widgets in memory, you cannot
 > put them directly in a vector, since vectors copy objects and widgets
 > instances cannot be copied. You can instead store pointers to your

I tried making a vector of RefPtr, but how do I instantiate a widget in
a RefPtr and placing it on a VBox?

std::vector<Glib::RefPtr<Gtk::Button> > buttons;

Glib::RefPtr<Gtk::Button> foo = Gtk::Button::Button("RefPtr Button",
false); // <--- does not work
m_VBox.pack_start(&buttons[0], Gtk::PACK_SHRINK); // <-- not sure how to
do it :(


Mj Mendoza IV,
Developer, KonsolScript

gtkmm-list mailing list
gtkmm-list gnome org

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