Re: [gtkmm] Gtk::DrawingArea help required



Timothy M. Shead wrote:

ej wrote:

The button signal handler works fine when I comment out the expose event handler connect line, but
with that line the program fails to compile with the following :

ejames sonata:/data/My_NEAT/StockDB/helloworld> g++ -o picture main.cpp Picture.cpp `pkg-config gtkmm-2.0 --cflags --libs`
Picture.cpp: In constructor `Picture::Picture()':
Picture.cpp:24: error: no matching function for call to `
  Glib::SignalProxy1<bool, GdkEventExpose*>::connect(SigC::Slot0<void>)'
/opt/gnome/include/gtkmm-2.0/glibmm/signalproxy.h:136: error: candidates are: SigC::Connection Glib::SignalProxy1<R, P1>::connect(const SigC::Slot1<R,
  P1>&, bool) [with R = bool, P1 = GdkEventExpose*]


The signature of event handlers is dictated by the signal; in this case, you have to provide a function that takes GdkEventExpose* and returns bool:

bool Picture::on_expose_event(GdkEventExpose*)
{
    std::cout << "expose event generated" << std::endl;
}

Cheers,
Tim

Thanks Tim.
I had a look at the docs for Gtk::Button and Gtk::widget and I've twigged about the signatures that event handlers need. Out of interest, can anyone out there explain why the Button event can make do with a void handler with no args, but the expose
event needs a boolean function taking a GDKEventExpose* ?

My next step...work out how to draw in my DrawingArea... :-)

Cheers,
EJ




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