user2653062
user2653062

Reputation: 717

Qt: How to add custom menu items in Application Menu in Mac?

I want to add a submenu in the application menu in Mac. The Application Menu already contains item "About myapp", "Quit myapp", etc. I want to add here a sub menu like "Themes" and then provide actions inside it like: "Theme 1", "Theme 2", etc.

So it should be like:

Menu Myapp->
    Themes->
        Theme 1
        Theme 2

Upvotes: 1

Views: 979

Answers (1)

p.i.g.
p.i.g.

Reputation: 3005

Main menu is your already existing menu. You can add a submenu with the following code

QMenu* mainMenu = new QMenu( "Menu" );

QMenu* themesMenu = new QMenu( "Themes" );
mainMenu->addMenu( themesMenu );

themesMenu->addAction( "Theme 1" );
themesMenu->addAction( "Theme 2" );

But I think you want to add some other input arguments to the addAction( ... ) function, such add the slot what shall be executed on the menu activating. Read this about this function.

enter image description here

Upvotes: -1

Related Questions