Results 1 to 2 of 2
Hello everyone,
I'm new too these forums but need a little help with a gtkmm project of mine. First off, I've been programming with Gtk+ and gtkmm for about 4-5 ...
- 08-07-2011 #1Just Joined!
- Join Date
- Aug 2011
- Posts
- 7
Recursively Creating Widgets during Run-time (gtkmm)
Hello everyone,
I'm new too these forums but need a little help with a gtkmm project of mine. First off, I've been programming with Gtk+ and gtkmm for about 4-5 years so I'm relatively seasoned at it. I'm no professional but I can get the job done. Currently in my project I am trying to create widgets after the program has executed and have them adapt to a template file that is read into memory. For the most part I have everything working but I cannot seem to get the signal handlers to connect properly with the appropriate field. For instance, I need to acquire a previous object that was allocated into the memory but was replaced by a new instance. The code looks something like this...
Now I need to be able to retrieve the objects created by this function for later use. (Especially the Entry field) So any help on this would be great. Below I provided the source files for the entire program if you need a better understanding of what I'm talking about.Code:void CiteMite::add_query_field(const Glib::ustring str) { //Creating new widgets and allocating dynamic memory m_hboxQuery = Gtk::manage (new Gtk::HBox(false, 5)); m_lbQuery = Gtk::manage (new Gtk::Label(str + ":", 1.00, 0.50, false)); m_entQuery = Gtk::manage (new Gtk::Entry); m_lbQuery->set_size_request(120, 30); //Unique Name Identifier m_hboxQuery->set_name(str + "_hbox"); m_lbQuery->set_name(str + "_label"); m_entQuery->set_name(str + "_entry"); //De-reference and pack widgets into Horizontal Packing Box m_hboxQuery->pack_start(*m_lbQuery, false, true, 2); m_hboxQuery->pack_start(*m_entQuery, true, true, 2); //De-reference and pack widgets into main Vertical Packing Box m_vboxQuery.pack_start(*m_hboxQuery, true, true, 5); show_all_children(true); };
Thank You,
Matt
- 08-08-2011 #2Just Joined!
- Join Date
- Aug 2011
- Posts
- 7
Alright so I gave a little to vague of a description so let me explain what I'm trying to do a little bit better...
First off, using the code above I want to encase it in a For() loop to create multiple input fields, like so...
NOTE: This is not the real use, I'm just simplifying to explain my pointCode:for (int i=0; i<10; i++) { add_query_field(str_data[i]); }
Next, using a member function from the same class I want to access those input fields and retrieve their text, like so...
I hope this helps clarify the issue at hand.Code:void CiteMite::on_btnOk_clicked() { Glib::ustring str_data[11]; for (int i=0; i<10; i++) { str_data[i] = m_entQuery->get_text(); } }
Thanks,
Matt


Reply With Quote