explicit signal connection vs. overriding function



I have looked at a few examples in the gtkmm online book. Several of them handle signals coming from widgets by connecting to signals like this:

class Buttons : public Gtk::Window
{
public:
  Buttons();
  virtual ~Buttons();

protected:
  //Signal handlers:
  void on_button_clicked();

  //Child widgets:
  Gtk::Button m_button;
};

.......
  m_button.signal_clicked().connect( sigc::mem_fun(*this, &Buttons::on_button_clicked) );

--------------
I saw another way to handle signals: by overriding the default signal handler. This is done for the DrawingArea widget:
http://library.gnome.org/devel/gtkmm-tutorial/unstable/sec-cairo-drawing-lines.html.en

where this can be found:
virtual bool on_expose_event(GdkEventExpose* event);

... and no explicit signal connection.

------------

This begs the question: are the two methods of handling signals equivalent? Is it always possible to choose either of them?





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