

Our application inherits the KMainWindow class, which automatically handles creating
a menu bar and tool bars for us. In the KScribble::setupActions() method there is
a call to KMainWindow::createGUI(). This method loads a resource file, in this
case kscribbleui.rc, to initialize menus at startup. Note that kscribbleui.rc is listed as one of the
project files in the Automake Manager. Opening that file up reveals this:
1 <!DOCTYPE kpartgui SYSTEM "kpartgui.dtd"> 2 <kpartgui name="kscribble" version="1"> 3 <MenuBar> 4 <Menu name="custom"><text>C&ustom</text> 5 <Action name="custom_action" /> 6 </Menu> 7 </MenuBar> 8 </kpartgui>
Explanation...
Another way to modify the contents of the menu and tool bars is to directly manipulate them through the
methods provided by their class. For example, the menuBar() method returns the
KMenuBar widget that the menubar for our program. Looking at the documentation for
KMenuBar and its inheritor class QMenuBar, you will find
a large number of insertItem() methods which allow you to add items to the
menu bar.
KMainWindow's methods statusBar() and
toolBar() will also provide you with applicable widgets.