简体   繁体   中英

Getting the text from a comboboxtext gtk3, c

I really searched a lot to find out the answer but didn't find anything. I created a comboboxtext using glade3 and inserted three text values. The comboboxtext is in a form and when the user presses the ok button of the form I want to store in const *char the text value he chose. What is the function that gets the text? I cannot see any in GTKcombobox .

edit : with

const *char d_string;
 GtkWidget *textvalue= GTK_WIDGET(gtk_builder_get_object(builderform[0], "comboboxtext1"));
  d_string=gtk_combo_box_get_active_id(GTK_COMBO_BOX(textValue));

I get a segmentation fault.

Use

    gtk_combo_box_text_get_active_text (GtkComboBoxText *cmb);

Since you did not set gtk_combo_box_set_active_id(), you cannot pull the active_id. Anyway, the "id" is used if you use GtkTreeModel to fill up the combo box.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM