Re: Callbacks and Signals works with Classes?



>no matches converting function `on_button_clicked'
>to type `void (*) ()'
>clases.h:400: candidates are: void
>myclass::on_button_clicked

this is member function. C++ member functions are not, and never have
been, interchangeable with regular C functions. this is a common
confusion among relatively new C++ programmers (i suffered from it
myself many years ago).

to do what you want you need:

   class myclass {
       static void on_button_clicked (myclass *);
   };

   gtk_signal_connect (GTK_OBJECT (button),
                           "clicked",
			    GTK_SIGNAL_FUNC (on_button_clicked),
			    this);

the "static" keyword makes the member function into something
equivalent to a regular C function.

or better yet, use Gtk-- (though many people don't agree with me on that).

--p




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