Custom Gtk Widget without ui file

Hi,

I try to create custom widget without using ui file only create all views in init function. But when I start app I cannot see this widgets.

Its link to my widget code:

Could someone help me with or have good instruction how to create custom widget. I try find answer at google but I didn’t find any tutorial.

Maybe this can help (written for GTK3):
https://wiki.gnome.org/HowDoI/CustomWidgets

First question: Are you using GTK3 or GTK4?

You want to add self->main_box to self (gtk_container_add). With GTK3, you would derive from a GtkBin, you can’t add children to GtkWidget in GTK3.

In GTK4 deriving from GtkWidget is fine.

You don’t need to override widget_class->realize at all, you don’t need gtk_widget_set_has_window().

I use GTK3.

So can I make custom widget which contains another widgets in GTK3?

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