Re: [gtkmm] Two beginners questions to signal handling



"Andreas B. Thun" <abt gmx de> writes:

> The callback function of form B should trigger
> the values displayed in form A to update.
> form A: build by constructor of class A
> form B: build by constructor of class B
>
> 1. Is there a way to connect the signal handler
>     B::something_in_B_selected() to A::update_values_in_A()?
>     class A : public Gtk::VBox
>     class B : public Gtk::VBox

You can define your own signals if that is what you are asking. You
can also connect to "someone clicked here" events in a widget if that
is what you are asking.

You just need to find the appropriate signal_something() to connect
to, then say something along the lines of

  signal_something().connect(SigC::slot(my_a_object, &A::update_values));

inside B.

When you are looking for a signal_something(), remember that base
classes define signals too. Sometimes it is easiest to find one via
the signal mechanism in Glade.

(If you are not using Glade, you really should unless _all_ of your
window contents are dynamically generated.)

> 2. If I want to update the values in a already
>     displayed form A is it ok to just re-set the values
>     and invoke show_all()?

You don't need to invoke show_all again. If you update the value in a
widget, it will automatically refresh itself.

-- 
Ole Laursen
http://www.cs.auc.dk/~olau/



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