如何获取 gtklistboxrow 的 child?

How to get the child of a gtklistboxrow?

如果您在列表框中添加项目,您可以使用 list_box.insert();现在有一个项目,你可以 select 它。对于我的示例,它是一个条目(文本框)。但是现在我想按下一个按钮并给我输入的值。我在 list_box 或 list_box_row 的参考文献中没有找到返回任何兼容 object 的函数。 我试过这样的东西:

gtk_entry_get_text(GTK_ENTRY(gtk_list_box_get_selected_row(GTK_LIST_BOX(listbox)))); //listbox is a variable of typ GtkWidget and contains the listbox in

但是它不起作用。有人有解决方案吗?我的意思是,如果您不能使用 selected 的东西,考虑列表框就有点没用了。

GtkListBoxRow 是一个 GtkContainer。特别是一个(单项)GtkBin: https://developer.gnome.org/gtk3/stable/GtkListBox.html#GtkListBoxRow

您应该可以拨打电话:

gtk_bin_get_child(GTK_BIN(listboxrow));

请注意,GtkListBoxRow 只能有一个 child,而 GtkListBox 可以有多个 GtkListBoxRows