RE: [gtkmm] Derived widgets and C object constructor



> From: Christer Palm [mailto:palm nogui se] 
> I'm trying to do something similar to glademm's 
> get_widget_derived() as 
> per the example code below, but my implementation of any on_XXX() 
> virtual function is not called.

That's because you are instantiating a GTK+ GType, not a gtkmm GType that
adds the extra c<->C++ hooks. libglade and libglademm have some extra code
to make libglade instantiate the gtkmm GTypes.

I don't know why you need to do
  new MyDialog( gtk_dialog_new() );
but I would try to avoid it.

If you really need to do it, you might use g_object_new(), providing the
gtkmm GType instead of GTK_TYPE_DIALOG. If you look at the implementation of
gtk_dialog_new() you should see that the _new functins are just convenience
wrappers for g_object_new(). Using g_object_new() is not a hack, by the way
- it's meant to work like that for GUI-builders and other things that don't
know the types until runtime.

Murray Cumming
murrayc usa net
www.murrayc.com
Remember to use the "Reply To All" feature with mailing lists.



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