我在Gtk :: TreeView中创建一个Gtk :: CellRendererCombo,如下所示:
Gtk::CellRendererCombo *someRenderer = manage(new Gtk::CellRendererCombo());
someRenderer->property_has_entry() = false;
someRenderer->property_text_column() = 0;
someRenderer->property_editable() = true;
someRenderer->property_model() = m_someListStore;
someRenderer->signal_edited().connect(sigc::mem_fun(*this, &SomeClass::onEdited));
col = manage(new Gtk::TreeViewColumn(_("Some Column Name"),*someRenderer));
将相应的列表存储“m_someListStore”创建为:
{
Gtk::TreeModel::ColumnRecord colRec;
colRec.add(someList_str);
colRec.add(someList_id);
m_someListStore = Gtk::ListStore::create(colRec);
}
Gtk::TreeModel::iterator itr1 = m_someListStore->append();
(*itr1)[lotInfoCol_id] = 0;
(*itr1)[lotInfoCol_str] = "Zero";
itr1 = m_someListStore->append();
(*itr1)[lotInfoCol_id] = 1;
(*itr1)[lotInfoCol_str] = "One";
etc...
我的问题是当我从CellRenderer Combo中选择它时,它由SomeClass :: onEdited方法处理。
void SomeClass::onEdited(const Glib::ustring& path_string, const Glib::ustring& new_text)
{
Gtk::TreePath path(path_string);
Gtk::TreeModel::iterator iter = m_TreeViewListStore->get_iter(path);
if(iter)
{
Gtk::TreeRow row = *iter;
row[m_TreeViewModel.some_column] = new_text;
}
}
new_text包含我的CellRendererCombo(someList_str)中的选定字符串值。有没有办法我也可以传入int id(someList_id)?
感谢。
答案 0 :(得分:0)
This page显示了如何使用sigc::bind<>
模板类将额外的参数传递给信号处理程序。
gtkmm开发人员似乎或多或少都不赞同,但对我来说(披露:在普通的旧C中使用相当长的背景编程GTK +),这感觉很自然。并非所有内容都是子类窗口小部件。