伙计们,
我要尝试制作一个与我制作的Gtk_tree_view有关的功能, 像这样的错误响应:
(main:8026): Gtk-CRITICAL **: IA__gtk_tree_view_get_model: assertion `GTK_IS_TREE_VIEW (tree_view)' failed
(main:8026): Gtk-CRITICAL **: IA__gtk_list_store_append: assertion `GTK_IS_LIST_STORE (list_store)' failed
(main:8026): Gtk-CRITICAL **: IA__gtk_list_store_set_valist: assertion `GTK_IS_LIST_STORE (list_store)' failed
^C
和来源,你走了:
void addlist(bahan *unit, const gchar *str)
{
GtkListStore *store;
GtkTreeIter iter; // penyambung store_append and store_set
store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(unit->treeview_aktifitas)));
gtk_list_store_append(store, &iter); // need unary &, coz iter aint define like a pointer
gtk_list_store_set(store, &iter, 1, str, -1);
}
正如你所想,“单位”的结构应该是这样的:
typedef struct
{
GtkWidget *window;
GtkWidget *notebook;
GtkWidget *start;
GtkWidget *verbose;
GtkWidget *settings;
GtkWidget *about;
GtkWidget *statusbar;
GtkWidget *treeview_aktifitas;
guint statusbar_id;
} bahan;
并通过此连接:
unit->treeview_aktifitas = GTK_WIDGET(gtk_builder_get_object(main,"treeview1"));
在实际案例中,我使用'glade 3',并且在glade文件上有两列,如何设置gtk_list_store_set?
非常感谢任何进一步的帮助:)
答案 0 :(得分:2)
gtk_list_store_set(store, &iter, 1, str, -1);
因为我的专栏是两个,所以我需要
gtk_list_store_set(store, &iter, 0,"aku", 1, "tes", -1);
其中0表示第一列,1表示下一列,依此类推-_-'