Timeout
You may be wondering how to make gtkmm do useful work while it's idling along. Happily, you have several options. Using the following methods you can create a timeout method that will be called every few milliseconds.
sigc::connection Glib::SignalTimeout::connect(const sigc::slot<bool()>& slot,
unsigned int interval, int priority = Glib::PRIORITY_DEFAULT);
The first argument is a slot you wish to have called when the timeout occurs. The second argument is the number of milliseconds between calls to that method. You receive a sigc::connection object that can be used to deactivate the connection using its disconnect() method:
my_connection.disconnect();
Another way of destroying the connection is your signal handler. It has to be of the type sigc::slot<bool()>. As you see from the definition your signal handler has to return a value of the type bool. A definition of a sample method might look like this:
bool MyCallback() { std::cout << "Hello World!\n" << std::endl; return true; }
You can stop the timeout method by returning false from your signal handler. Therefore, if you want your method to be called repeatedly, it should return true.
Här är ett exempel på denna teknik: