What is the difference between <child> and <property name="child">?

G’day,

I’m working with GTK4 templates and I’m not sure what the difference is between these tags:

<child>

<property name="child>

Thanks again,

J.R.

The latter is the syntax for setting a property named “child”; it’s typically employed by widgets that can contain a single child, or children in specific roles mapped to specific properties.

The former is the generic “pack a widget into another widget” syntax; it is used with widgets that can contain an arbitrary amount of children, and it follows the same order as the UI definition.

For instance:

  • GtkWindow has a single child, and a child property, so you should use the latter format
  • GtkBox can have multiple children, so it cannot use a single property; you should use the former format
1 Like

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