Re: help on array of widgets



Thanks for the snippet Yann!

Now how do I properly handle which button was clicked?

What I did was:
(*buttons.back()).signal_clicked().connect(sigc::mem_fun(*this, &HelloWorld::onButtonsClick));
//...
void HelloWorld::onButtonsClick() {
  //who was clicked?!?
}


Regards.

Mj Mendoza IV,
Developer, KonsolScript
http://www.konsolscript.org



From: Yann Leydier <yann leydier info>
To: gtkmm-list gnome org
Sent: Wednesday, July 27, 2011 7:30:48 PM
Subject: 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.

Yann



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