Issues creating gtk4 dropdown

Hello, I’m having trouble understanding the documentation for dropdowns in gtk4 and all the help online seems to be for combo boxes which are now deprecated. This is my code:

const char* options[] = { “1”, “5”, “7”, “9” };
//seg fault on this line
GtkWidget* dropdown0 = gtk_drop_down_new_from_strings (options);

Any help would be appreciated.

The array of strings must be NULL-terminated:

Screenshot from 2022-12-21 17-17-41

Use this, instead:

GtkWidget *dropdown =
  gtk_drop_down_new_from_strings ((const char *[]) {
                                    "1",
                                    "5",
                                    "7",
                                    "9",
                                    NULL,
                                  });
1 Like

Wow! That was a real head-scratcher, thanks!

Exactly what I was looking for.

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