Hello, good day,
How to use a ComboBox with a liststore? Example below doesn’t fill any item in the combo. Tried the examples in gtk-rs github, but there is only one example about liststore, thats very hard to understand, and nothing about a combobox.
let store = gtk::ListStore::new(&[String::static_type()]);
for _ in 0..10 {
store.set(&store.append(), &[(0, &"I'm a child item")]);
//store.insert_with_values( Some(i), &[(0, &"I'm a item of the list")]);
}
label_combo.set_model(Some(&store));
Ah, if you’re still on GTK3 you probably want to use gtk::ComboBoxText. Otherwise you’ll have to set a CellRenderer which renders the text of yours. See the documentation of ComboBox for that:
The GtkComboBox uses the model-view pattern; the list of valid choices is specified in the form of a tree model, and the display of the choices can be adapted to the data in the model by using cell renderers, as you would in a tree view. This is possible since GtkComboBox implements theGtkCellLayout interface. The tree model holding the valid choices is not restricted to a flat list, it can be a real tree, and the popup will reflect the tree structure.