How can I use an GtkOverlay widget in a Composite Template - Solved

Using composite templates, as I have for my entire project, I have been trying to overlay some text over a drawn image using an Overlay but can’t seem to find the right incantation. The examples I found with Google all seem incorrect.

What I am trying to do should be obvious from this broken example

  <template class="AirportMapView" parent="GtkBox">
    <child>
      <object class="GtkOverlay" id="overlay">
        <property name="child">
          <object class="GtkDrawingArea" id="airport_map_window">
            <property name="vexpand">true</property>
            <property name="hexpand">true</property>
          </object>
        </property>
        <property name="overlay">
          <object class="GtkLabel" id="overlay_child2">
            <property name="label">Overlay Child 2</property>
            <property name="valign">end</property>
            <property name="halign">end</property>
          </object>
        </property>
      </object>
    </child>
  </template>

Hi,

What about this?

        <child type="overlay">
          <object class="GtkLabel" id="overlay_child2">
            <property name="label">Overlay Child 2</property>
            <property name="valign">end</property>
            <property name="halign">end</property>
          </object>
        </child>

“overlay” is not a property. It’s a qualifier type for child widgets.

Thanks @gwillems that worked perfectly :slight_smile:

1 Like

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