Re: Gtk::CellRendererCombo how to



https://git.gnome.org/browse/gtkmm-documentation/tree/examples/book/treeview/combo_renderer


On 02/10/2017 06:17 AM, p_solntsev meta ua wrote:
Hi,

Could you please provide a simple example how to use
Gtk::CellRendererCombo in Gtk::TreeView?

What I have for now is two column Gtk::TreeView. In first column (each
raw) I need ComboBox.

I have the following class for ComboModel. Is it necessary to have m_id
member?

class ModelColumnsRender : public Gtk::TreeModelColumnRecord
{
public:

   ModelColumnsRender()
     { add(m_name); }

   Gtk::TreeModelColumn<Glib::ustring> m_name;
}m_columnsrender;

Using m_columnsrender I can create a Gtk::ListTree model and populate it.

For TreeView itself, I also have the similar class as mentioned above:

class ModelColumns : public Gtk::TreeModelColumnRecord
{
public:

   ModelColumns()
     { add(m_name); add(m_amount) }

   Gtk::TreeModelColumn<Glib::ustring> m_name;
   Gtk::TreeModelColumn<Glib::ustring> m_amount;

}m_columns;

I can also create a ListStore model using m_columns.

Now I do the following:
// Create a column
auto render = Gtk::manage(new Gtk::CellRenderCombo);
auto pCol = Gtk::manage(new Gtk::TreeViewColumn("Animals"));

pCol->pack_start(*render, true);
treeview->append_column(*pCol);
treeview->append_column("Amount",m_columns.m_amount);

How can I add a model to my render? I tried

render->property_model() = refListStoreModelForCombo;

But no effect.

Where should I define the model for CellRenderCombo? inside of
ModelColumns class if so, how can I populate it?

Thanks.

-Pavlo





______________________________
Жіноча нижня білизна від Anabel Arto
http://go.meta.ua/anabel_lingery_ua

_______________________________________________
gtkmm-list mailing list
gtkmm-list gnome org
https://mail.gnome.org/mailman/listinfo/gtkmm-list

--
Saying what we think gives us a wider conversational range than saying what we know.
   — Cullen Hightower


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