Monday, 15 February 2010

c++ - How can I associate data - a string, integer or enum member - with a Gtk::ComboBoxText item? -



c++ - How can I associate data - a string, integer or enum member - with a Gtk::ComboBoxText item? -

i using gktmm 3.0 on ubuntu 12.04 box default gcc toolchain.

in c# world, combobox class has comboxbox.item[n].value property, allows associate each item in combobox data.

i looking similar in gtk::comboboxtextclass. how can associate info - string, integer or enum fellow member illustration - particular gtk::comboboxtextitem?

i know many frameworks provide genericdata pointer on widgets such use, quite mutual need.

is there in gtk::comboboxtext class or 1 of parent classes might allow me accomplish this, or need set such association myself, using map or other associative collection?

the gtk::comboboxtext append, insert() , prepend() methods allows specify id string human-visible text. instance: https://developer.gnome.org/gtkmm/stable/classgtk_1_1comboboxtext.html#a19e80f4e451e23d2c00d3fb11023f9f2

but clearer , more type-safe utilize gtk::combobox , define actual underlying model contains associated data. illustration uses int, utilize other types or utilize more columns: https://developer.gnome.org/gtkmm-tutorial/stable/combobox-example-full.html.en

c++ combobox gtk associative-array gtkmm

No comments:

Post a Comment