Re: Storring value in treeview



The type of row[m_columns.m_type] is not myclass::MyType, it's Gtk::TreeValueProxy<myclass::MyType>. I'm not sure what happens when you print a TreeValueProxy<myclass::MyType> with std::cout <<. It might be its address that's printed.

Some alternatives that I believe will work:
std::cout << row.get_value(m_columns.m_type) << std::endl;
std::cout << static_cast<myclass::MyType>(row[m_columns.m_type]) << std::endl;

/Kjell

Den 2016-10-30 kl. 03:59, skrev Pavlo Solntsev:

Hi,
Simple example:
class myclass {
enum MyType {
None = 0,
Firsttype ,
Secondtype
};
}

I have a class member that returns MyType. Let's call it get_type (). 
Some code exame:
void myfunc (sometype obj)
{
Gtk::TreeModel::Row row =*(m_refTreeView-> get_selected ());
row[m_columns.m_type] = obj.get_type ();
// checking code
std::cout << "1typ is " << obj.get_type () << std::endl;
std::cout << "2typ is " << row [m_columns.m_type]  << std::endl;
}
m_columns.m_type is MyType type.
I don't understand,  why I see different outputs. In the first case I have the correct value 1 or 2, while in thesecond one I see a random value 86363773. 

I have many columns and have no problems with them. 
Could you please clarify what I missed. Let me know if you need more information.
-Pavlo.
Thanks.




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