comment conecter un bouton à une fonction?
Bonjour,
voici mon code:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
| #include<libglademm.h>
#include<gtkmm.h>
#include<iostream>
Gtk::Window* p_w = 0;
Gtk::Button* p_b = 0;
void monsignal();
int main(int argc, char ** argv)
{
Gtk::Main kit(argc, argv);
//Load Glade file and instantiate its widgets
Glib::RefPtr<Gnome::Glade::Xml> refXml;
#ifdef GLIBMM_EXCEPTIONS_ENABLED
try
{
refXml = Gnome::Glade::Xml::create("winglade-test.glade");
}
catch(const Gnome::Glade::XmlError& ex)
{
std::cerr<< ex.what()<<std::endl;
}
#else
std::auto_ptr<Gnome::Glade::XmlError> error;
refXml = Gnome::Glade::Xml::create("winglade-test.glade","","",error);
if(error.get())
{
std::cerr<<error->what()<<std::endl;
return 1;
}
#endif
//Get the Glade instantiate window
refXml->get_widget("window1", p_w);
refXml->get_widget("button1", p_b);
if (p_w && p_b)
{
std::cout<<"Tout va bien"<<std::endl;
p_b->clicked().connect(sigc::ptr_fun(monsignal));//la ligne qui cloche
kit.run(*p_w);
}
return 0;
}
void monsignal()
{
std::cout<<"hi hi hi"<<std::endl;
} |
et voici ce que me retourne le compilateur:
Citation:
/home/.../main.cc||In function `int main(int, char**)`:
/home/.../main.cc|43|erreur: invalid use of `void`
||=== Build finished: 1 errors, 0 warnings ===|
Voila 3 4 jours que je tache de reproduire des exemples de code trouvés dans la doc et sur le net et ceci est mon meilleur résultat. Qu'est-ce qui ne va pas?