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:
https://git.gnome.org/browse/gtkmm-documentation/tree/examples/book/t
reeview/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

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

gnuinos.org/simple-netaid-gtk.mpg

Shortly, i'll share the code in gitlab.

Cheers,

  Aitor.








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