Re: Creating widgets at runtime

On Wednesday 13 September 2006 15:08, andypaxo wrote:
> From all the replies given I am now doing the following:
> - Creating a widget via new()
> - Adding it to a container
> - Using gtkmm's manage() to take care of it after that
> And now widgets can be created and got rid of at any time during execution.

If what you are doing is creating objects on demand, that's generally the way 
to do it, but creating objects on freestore with the new expression can be 
quite time/CPU intensive and if the widget is likely to be frequently used, 
instead of deleting it and then recreating it later, it can be better just to 
hide it and then show it again (or call Gtk::Window::present() if it is an 
entire window) on demand.

Another alternative for a frequently used widget which is only shown on demand 
is to create it statically and add and remove it from its container (and/or 
show and hide it) as required.


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