Re: GtkComboBox



Hi,

Pramod Patangay <pramod patangay gmail com> writes:

> I was trying out GtkComboBox. I have Gtk-2.4. I have created a
> GtkTreeModel and populated the corresponding GtkTreeStore. But when I
> run the program, the entries are not shown. Why is this happening? I
> am attaching the program here:
>
> GtkTreeStore *ts = gtk_tree_store_new(1,G_TYPE_STRING);
> 	GtkWidget *tv = gtk_tree_view_new_with_model(GTK_TREE_MODEL(ts));
> 	GtkCellRenderer* cr = gtk_cell_renderer_text_new();
> 	GtkTreeViewColumn* tvc =
> gtk_tree_view_column_new_with_attributes(NULL, cr, "text", 0, NULL);
> 	gtk_tree_view_append_column (GTK_TREE_VIEW(tv), tvc);
> 	gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(tv), FALSE);
> 	GtkTreeSelection* TS = gtk_tree_view_get_selection(GTK_TREE_VIEW(tv));
> 	gtk_tree_selection_set_mode(TS, GTK_SELECTION_BROWSE);
>
> 	GtkTreeIter iter;
>
> 	gtk_tree_store_insert(ts, &iter, NULL, 0);
> 	gtk_tree_store_set(ts, &iter, 0, "FIRST",-1);
>
> 	gtk_tree_store_insert(ts, &iter, NULL, 0);
> 	gtk_tree_store_set(ts, &iter, 0,"SECOND",-1);
> 	
> 	GtkWidget* combo = gtk_combo_box_new_with_model(GTK_TREE_MODEL(ts));
> 	gtk_container_add(GTK_CONTAINER(dialog),combo);
> 	gtk_widget_show(combo);
>
> Can anyone please point out, why the entries are now show n in the combo box?

Your combobox only has a model. You need to add a cell-renderer to the
combo-box.


Sven



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]