// Tree model columns: but I don't want this in the code// I think glade can put it in the XMLstruct ModelColumns : Gtk::TreeModel::ColumnRecord {ModelColumns() {add(m_col_name);}Gtk::TreeModelColumn<Glib::ustring> m_col_name;} m_Columns;
m_refTreeModel = Gtk::ListStore::create(m_Columns);pComboBoxEntry1->set_model(m_refTreeModel);// It be nice to put initial rows in the glade file too// although I do want to add the ones that the user createsGtk::TreeModel::Row row = *(m_refTreeModel->append());row[m_Columns.m_col_name] = "Option 1";row = *(m_refTreeModel->append());row[m_Columns.m_col_name] = "Option 2";row = *(m_refTreeModel->append());row[m_Columns.m_col_name] = "Option 3";pComboBoxEntry1->set_text_column(m_Columns.m_col_name);
Hi,
create a combox, and a liststore in glade (assign the liststore to the
combobox entry.
Then in c++, if you use Gtk::Builder (instead of libglade):
Glib::RefPtr<Gtk::Builder> b =
Gtk::Builder::create_from_file("simple.glade")
m_liststore = dynamic_cast<Gtk::Liststore>
b->get_object("liststore_name");
Gtk::ComboBoxEntry *combo;
b->get_widget("combox_name", combo);
combo->signal_changed().connect(sigc::mem_fun(this,
&App::combo_changed));
void App::combo_changed() {
Gtk::TreeModel::Row row = *(m_liststore->append());
row.set_value(0, combo->get_active_text());
}
well i think almost like this ;)
best regards
Am Sonntag, den 19.09.2010, 10:32 +1200 schrieb Chris Scaife:
> _______________________________________________> I'm new to gtkmm and glade and trying to make my second gui app with
> it. Alas getting confused by all the different tutorials and
> explanations out there on the web.
>
>
> What I want to do is have something like a ComboBoxEntry widget that
> has a menu of options (utf8 character strings). Preferably, I just
> want to define these in the XML file that Glade produces.
>
>
> The idea is that the user can select one and edit it as he/she wishes.
> Then that edited value gets used bt the program when the Enter key is
> pressed, or perhaps by clicking a button somewhere.
>
>
> If anyone can explain what I need, or can tell me of a web site that
> shows how to do this (using glade and gtkmm with C++) it be much
> appreciated :)
>
>
> gtkmm-list mailing list
> gtkmm-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtkmm-list
Attachment:
combo.tar
Description: Unix tar archive