How to create a File Menu in GTK4

Hi,
I’m looking to create a menubar in my application window as I need the window to look somewhat like a standard application for Windows. Hence, I need to add File, Edit, Help etc. with associated menu items and sub menus.

I have tried to follow the documentation but was mostly just left confused and unable to get the menu displayed. I did achieve this in GTK3 but in GTK4 I have not been able to make any progress.

I was therefore hoping someone had a simple example of how to do this with a ui (xml) file as per the documentation. I could post my code but as I’m thoroughly lost at this stage there is likely no point.

I have read through the post about migrating from GTK3 to GTK4 but was not able to get that code example to work with my application.

Any advice would be much appreciated.

Thank you.

See that tutorial:

Hi Vincent,

This repo is a gold mine! I didn’t even know it existed, perhaps there was a link I missed, but anyway thank you very much, it is perfect.

Regards,
Adam.

1 Like