How to change scale widget when spinbutton changes.



Hello. I'm trying to do a pair of widgets in a window which change their values
whenever any of them changes. In the signals connection, looking at the documentation
I can't see an obvious way to connect a slot to a signal for spinbutton in order
to change the scale widget.

I looked for a signal in spinbutton that emits the value when changes, but found none.
I want to set the value for the scale when the SpinButton changes. The code so far:

#include <gtkmm.h>
#include <boost/bind.hpp>


int main(int argc, char * argv[])
{
    Gtk::Main m(argc, argv);
    Gtk::Window w;

    Gtk::VBox vb;
    Gtk::HBox hb;
    vb.pack_start(hb, false, false, 6);
   
    hb.set_spacing(6);

    w.add(vb);

    Gtk::SpinButton sb;
    sb.get_adjustment()->set_lower(0);
    sb.get_adjustment()->set_upper(130);
    sb.get_adjustment()->set_step_increment(1);
    sb.get_adjustment()->set_value(20);

    Gtk::HScale scale;
    scale.set_range(0, 130);
    scale.get_adjustment()->set_value(20);


    scale.set_digits(0);
    hb.pack_start(sb, false, false, 6);
    hb.pack_start(scale, true, true, 6);

    //No problem with this
    scale.signal_adjust_bounds().connect(boost::bind(&Gtk::SpinButton::set_value, &sb, _1));

   //Problem. What should I connect? I can't find an obvious solution
   sb.signal_something.connect(slot_that_changes_scale_value);
    w.show_all();
    Gtk::Main::run(w);
}


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