Displaying a menu described in builder

I added this XML to tell builder to include a menu in my application, and although the rest of the user interface appears (with no error messages), no menu is displayed. I put the relevant XML near the start of the XML file, before the start of the GtkAppilcationWindow. Am I missing something simple? I saw what somebody else (named compyx, on Jan. 2nd) added in another conversation and tried their XML, but it didn’t work either.

type <?xml version="1.0" encoding="UTF-8"?>
  <requires lib="gtk" version="4.0"/>

  <menu id="rootmenu">
    <submenu id="File">
      <attribute name="label">File</attribute>
        <attribute name="label">Open</attribute>
  <object class="GtkApplicationWindow" id="main_ApplicationWindow">or paste code here

See GtkApplication Automatic resources. The menu must have id menubar and be placed in a resource gtk/menus.ui. Or see the example here for how to do it manually: A GtkApplicationWindow with a menubar.

Also the show-menubar property must be set on your ApplicationWindow:

<object class="GtkApplicationWindow">
  <property name="show-menubar">1</property>
  <!-- ... -->

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