Re: gtkmm-list Digest, Vol 154, Issue 2

Hi all,

On 02/11/2017 01:00 PM, Pavlo Solntsev <p_solntsev meta ua>  wrote:
Thank you so much, Phil. I didn't realized I have to insert ListStore model as value for each row. Also, a little bit confusing was part render->property_editable() = true. I see logic here now, but it wasn't clear. Surprisingly, I wasn't able to locate this example on the web site. Thanks again. -Pavlo. On Fri, 2017-02-10 at 06:43 -0800, Phil Wolff wrote:

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

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
raw) I need ComboBox.

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

class ModelColumnsRender : public Gtk::TreeModelColumnRecord

?????{ add(m_name); }

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

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

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

class ModelColumns : public Gtk::TreeModelColumnRecord

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

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


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);

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?



I'm using a ListStore in one of my projects in gtkmm:

Shortly, i'll share the code in gitlab.



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