1

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
p.i.g.
  • 2,815
  • 2
  • 24
  • 41
user2653062
  • 697
  • 1
  • 9
  • 16
  • To me it seems that this is not supported in a convenient way. While you can call setMenuRole(QAction::ApplicationSpecificRole) for QAction objects this method doesn't exist for QMenu. Probably you have to create the whole menu structure on your own. – pi3 Dec 20 '16 at 19:33

1 Answers1

-1

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

p.i.g.
  • 2,815
  • 2
  • 24
  • 41