所选项

要了解用户从组合框中选择了哪一项可以调用ComboBox::get_active()。这将返回一个TreeModel::iterator,你可以解引用它得到一个Row,然后从其中读取该列的值。例如,你可以在组合框中只显示人类可读的描述,然后你可以读取模型中储存于该行的整数ID值(于并未被显示的列)。例如:

Gtk::TreeModel::iterator iter = m_Combo.get_active();
if(iter)
{
  auto row = *iter;

  //Get the data for the selected row, using our knowledge
  //of the tree model:
  auto id = row[m_Columns.m_col_id];
  set_something_id_chosen(id); //Your own function.
}
else
  set_nothing_chosen(); //Your own function.