[gtkmm] Basic signal handling problem



Hi. I have a basic problem with signals in gtkmm. I'm
a begginer. I'm written this simple HelloWorld :


class A
{
public:
  A();
  void test(){cout << "test\n";}
};

class HelloWorld : public Gtk::Window
{
  Gtk::Button m_button;

public:
  HelloWorld();

  virtual int delete_event_impl(GdkEventAny *event);
  
};


// This is a callback that will hand a widget being
destroyed.
void destroy_handler()
{
  Gtk::Main::quit();
}


HelloWorld::HelloWorld()
  : Gtk::Window(GTK_WINDOW_TOPLEVEL), 
    m_button("Hello World")   
{
  destroy.connect(slot(&destroy_handler));

  set_border_width(10);
          
 
m_button.clicked.connect(SigC::slot(m_button,&A::test));

  add(m_button);

  m_button.show();
  
  show();

}




int HelloWorld::delete_event_impl(GdkEventAny *event)
{
  cout << "delete event occured" << endl;
  return true;
}

  
int main (int argc, char *argv[])
{
  Gtk::Main kit(argc, argv);

  HelloWorld helloworld;

  kit.run();
  return 0;
}




But the code doesn't compile. The compiler (g++)
responses with :

libsigc++/include/sigc++-1.0/sigc++/object_slot.h: In
function `class SigC::Slot0<void> SigC::slot<void,
Gtk::Button, A>(Gtk::Button &, void (A::*)())':
helloworld.cc:45:   instantiated from here

libsigc++/include/sigc++-1.0/sigc++/object_slot.h:129:
no matching function for call to
`SigC::ObjectSlot0_<void,A>::create (Gtk::Button *,
void (A::* &)())'

libsigc++/include/sigc++-1.0/sigc++/object_slot.h:60:
candidates are: static struct SigC::SlotData *
SigC::ObjectSlot0_<void,A>::create(A *, void (A::*)())

I don't understantd it, because the documentation says
that we can use any kind of function (static, class
member, ....). But if I use a member function from a
GTK derived class, such Gtk::Window, all it's correct.
All handled class member functions must be from a Gtk
derived class?
Anybody can helps me? Thanks.

_______________________________________________________________
Yahoo! Messenger
Nueva versión: Webcam, voz, y mucho más ¡Gratis! 
Descárgalo ya desde http://messenger.yahoo.es



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