【问题标题】:How to get the selected row from a TreeView如何从 TreeView 中获取选定的行
【发布时间】:2020-04-08 13:41:42
【问题描述】:

我有一个包含两列的 treeView。我有这个方法应该在选择一行时调用:

private Aircraft get_selected_aircraft () {
}

它将从第一列的注册中返回一架飞机。但是如何获得这个注册呢?我有一个TreeSelection,我可以使用get_selected_rows (),但即使这样我仍然不知道该怎么做......

【问题讨论】:

  • 请附上MCVE
  • 使用 gtk_tree_selection_get_selected

标签: treeview gtk vala


【解决方案1】:

连接到 TreeSelection 上的changed 信号。

听起来您可能还想确保选择处于 GTK_SELECTION_SINGLE 模式(在 Glade 中完成或通过在 TreeSelection 上调用 set_mode() 完成。

【讨论】:

    【解决方案2】:

    这里有一些例子:

    根据您用作TreeModel 的商店类型,您应该阅读TreeStore 和/或ListStore 文档。

    获取值的关键方法是TreeModel.get ()

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-11-08
      • 2013-05-13
      • 2015-05-15
      • 1970-01-01
      • 2021-10-01
      相关资源
      最近更新 更多