Re: Do widgets have to be members of class?



Thanks Daniel.  Thats exactly what I was looking for and it works perfectly!



Daniel Elstner wrote:
> 
> Am Dienstag, den 15.09.2009, 14:24 +0200 schrieb Krzesimir Nowak:
> 
>> Your label in constructor has local scope, so after constructor finishes
>> its activity, label is destroyed. So yes, it has to be a member of your
>> class. Or have global scope, which is ugly.
> 
> Eeek, no.  Just use Gtk::manage() and container ownership:
> 
>     Gtk::Label *const label = new Gtk::Label("LABEL");
>     table.attach(*Gtk::manage(label), 0, 1, 0, 1);
> 
> Personally, I use Gtk::manage() for widgets more often than not.  I do
> not make widgets member of a class if the code does not need to access
> it after construction.
> 
> --Daniel
> 
> 
> _______________________________________________
> gtkmm-list mailing list
> gtkmm-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtkmm-list
> 
> 

-- 
View this message in context: http://www.nabble.com/Do-widgets-have-to-be-members-of-class--tp25447078p25463277.html
Sent from the Gtkmm mailing list archive at Nabble.com.



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