Re: [gtkmm] How do you determine iterator 'type' for get_children.begin() ?
- From: Sergio Pascual <spr astrax fis ucm es>
- To: Jeff Gavin <jeff ezclick net>
- Cc: gtkmm-list gnome org
- Subject: Re: [gtkmm] How do you determine iterator 'type' for get_children.begin() ?
- Date: Wed, 11 Jun 2003 19:33:30 +0200 (CEST)
Well, I think is something like this:
Gtk::Box_Helpers::BoxList& boxlist = buttonbox.children();
for(Gtk::Box_Helpers::BoxList::iterator
i=boxlist.begin();i!=boxlist.end();i++){
Gtk::Button* button=dynamic_cast<Gtk::Button*>(i->get_widget());
}
Cheers, Sergio
On Wed, 11 Jun 2003, Jeff Gavin wrote:
> I'm trying to loop through each button in a button box and collect the
> pointers to each of the button widgets. So far I can do the following
> because I know that there are 8 buttons in the button box.
>
> button[0] = (Gtk::Button *) *(buttonbox->get_children().begin());
> button[1] = (Gtk::Button *) *(buttonbox->get_children().begin()++);
> button[7] = (Gtk::Button *) *(buttonbox->get_children().end());
>
> The above code compiles and does what I want, it gives me the first,
> second, and last button in my button box.
>
> I cannot figure out what type 'i' should be in this example:
>
> <WHAT TYPE GOES HERE?> i;
> for (i = buttonbox->get_children().begin();
> i <= buttonbox->get_children().end();
> i++)
> {
> button[j] = *(i);
> }
>
> How do you determine the type of the iterator. I have tried to find an
> example but cannot. I have read and re-read the online documentation
> for ListHandle and am very lost.
>
> I even compiled the program with the type of 'int' and the compiler
> complained:
>
> cannot convert
> `Glib::Container_Helpers::ListHandleIterator<Glib::Container_Helpers::TypeTraits<Gtk::Widget*>
> >' to `int' in assignment
>
> I was hoping that the error message would give me a hint, but I'm still
> not able to figure out the correct type to use for the iterator.I know
> that an experienced C++ programmer would then know exactly what type to
> use, but alas, I'm still new to C++.
>
> Thanks for your help.
>
> Jeff
>
> _______________________________________________
> gtkmm-list mailing list
> gtkmm-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtkmm-list
>
--
<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
Sergio Pascual Ramírez spr astrax fis ucm es
Tf: (+34) 91-394-50-18 Fax: (+34) 91-394-46-35
Dept. Astrofísica Facultad de C.C. Físicas
Universidad Complutense de Madrid
28040 Madrid (Spain)
------------------------------------------------------------------------------
Spanish junior researchers fight for employment rights
http://www.precarios.org
<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]