In QML/Qt6.5 I try to add/remove a Menu from the MenuBar of a ApplicationWindow dynamically and I don't find a solution. I can hide MenuItems but not the Menu itself.
ApplicationWindow
{
    id: mainWindow
    width: 600
    height: 400
    visible: true
    menuBar: MenuBar {
        id: mainMenuBar
        // this item should be shown/hidden at runtime
        Menu {
            id: subMenu
            title: "Menu to hide"
            MenuItem {
                text: "Menu Item"
            }
        }
    }
}
I have tried several things. Best so far was setting the title to an empty string, but in this case the Menu is still there (you can see it if you hover the area). Anyone having a solution for that?
Setting the height to 0 is also not working properly.