I have a gtkmm TreeView using ListStore. I am using this as a static list selection menu. I am having problems seeing when the user changes rows and which row is selected.
I have attempted to use m_TreeView.signal_row_activated().connect( sigc::mem_fun(*this, &optionList::row_activated) );
but get the error of
error: no match for call to ‘(sigc::bound_mem_functor0<void, optionList>) (const Gtk::TreePath&, Gtk::TreeViewColumn* const&)’ { return functor_(_A_arg1, _A_arg2); }
I have also attempted to use changed signals, but I receive the same errors. I have not been fruitful in finding these errors on Google. I have also not seen another way to create a static list selection menu.
My code is as follows:
optionList::optionList() {
set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
add(m_TreeView);
m_refListStore = Gtk::ListStore::create(m_Columns);
m_TreeView.set_model(m_refListStore);
m_TreeView.set_activate_on_single_click(true);
std::array<Glib::ustring, 3> options = {"Status", "Plugins", "Config"};
for(const auto & option : options) {
std::ostringstream text;
text << option;
Gtk::TreeModel::Row row = *(m_refListStore->append());
row[m_Columns.m_col_text] = text.str();
}
m_TreeView.append_column("Options", m_Columns.m_col_text);
m_TreeView.signal_state_changed().connect( sigc::mem_fun(*this, &optionList::row_activated) ); //This line produces the error
show_all_children();
}
the optionList::row_activated
function is just a cout
so I know it's at least being activated. If I remove the connecting line, then it compiles and runs fine, but I don't have any way to tell if it's being selected.
I am expecting to see the phrase A row has been selected
in the console (as that is what row_activated
outputs) every time I select a different row. However, I am not able to even compile the code with the aforementioned line included.
At the very least, how can I resolve this connection issue so that the code can compile and activate the function?
Edit: I believe that I was messing up and needed to send using sigc::bind()
The best answer I could come up with is that I was not properly passing and to do this I need to use
m_TreeView.signal_state_changed().connect( sigc::bind(sigc::mem_fun(*this, &optionList::row_activated), any parameters) );