Scrollable ComboBox

Hi everyone,

I am trying to use combobox in the following example ;

https://developer-old.gnome.org/gtkmm-tutorial/stable/combobox-example-simple.html.en

but when items are larger than a certain value I can not scroll there are no arrows to slide. Keyboard does not help as well. How can I makethe combobox scrollable ? Thanks in advance

I assume that you use gtkmm4 (not gtkmm3). If so, don’t use ComboBox. It’s
deprecated since gtk/gtkmm 4.10. Use Gtk::DropDown. It’s available since gtk/gtkmm 4.0.

https://developer-old.gnome.org/gtkmm-tutorial is, as its name shows, old. It’s not updated any more.
Look at https://gnome.pages.gitlab.gnome.org/gtkmm-documentation.
See for instance the examples at
https://gnome.pages.gitlab.gnome.org/gtkmm-documentation/sec-dropdown-search.html

1 Like

You should also show what exact code you have so far and ideally a screenshot of the unwanted result, so that readers have some context to suggest possible causes or improvements.

Thank you for the examples DropDown seems to solve the issue. But I was wondering how to add/append items to the DropDown for example after a button click ?

You append items to the list model to add new elements to the drop down.

1 Like
const Glib::ustring label = "test";
m_StringList  = Gtk::StringList::append(label);
m_DropDown.setmodel(m_StringList);
m_DropDown.set_selected(0);

returns this when I try to compile ;


error:cannot call member function 'void Gtk::StringList::append(const Glib::ustring&)' without object

what am I doing wrong ?

I resolved the issue my mistake was ;

m_StringList -> append(label)

Thanks!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.