windowsMenu = new KPopupMenu( this );
connect( windowsMenu, SIGNAL( aboutToShow() ),
this, SLOT( windowsMenuAboutToShow() ) );
menuBar()->activateItemAt(-1); //needed as insertItem might crash if a menu is activated
// position: 2, means the third menu (the fourth one is Help)
menuBar()->insertItem( "&Window", windowsMenu, -1, 2);
However, the "Window" menu was never added to the application.
Actually, I know that one should add additional menus to the .rc file, e.g.,
<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
<kpartgui name="sourcehighlightide" version="1">
<MenuBar>
<Menu name="custom"><text>C&ustom</text>
<Action name="custom_action" />
</Menu>
</MenuBar>
</kpartgui>
but I wanted a way to add the menu programmaticaly, so that I would not depend on the .rc file that must be installed.
Actually, the code added by me above works, but you must make sure to execute it after the call to setupGUI().
Hope this saves some headache to others wanting the same thing :-)
No comments:
Post a Comment