The first thing to add to the GUI are some top level File and Help menus with menu entries under them. Menu entries are added to each top level menu using actions. Actions can also be added to the tool bar. For now the File menu will contain an Exit entry and the Help menu will contain the About and About Qt entries. A separator is added before the Help menu so that Qt knows to put this menu on the right side of the menu for those styles that support this (Windows does not do this and KDE only does this for certain application appearance styles).
Actions contain information including the name of the action (an ampersand '&' is put in front of the character that is the hot key for the entry), along with an optional shortcut key, icon, and a status tip. No icons were added to any of the entries at this time. A connection is made from the triggered signal of each action to the function that will perform the action.
All the actions are created in the createActions() function and the menus are created in the createMenus() function, both called from the MainWindow constructor. The about() function was moved from the private section to the private slots section of the class definition so that the connection can be made from the about action. The temporary show() function was removed since it is no longer needed. The size of the header for program name in the About box was reduced to match the header size in the About Qt box.
Now the GUI will start, but doesn't do much beyond the menus (see image below). The window still has the default name given when the MainWindow class was created and there is just a generic program icon. There is also a blank tool bar under the menu bar. The dot or two on the left side of the tool bar allows the bar to be dragged to any side of the window and even detached from window. Icons (via actions) will be added to the tool bar later.
[commit 16e6755c0d]
Saturday, December 15, 2012
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment
All comments and feedback welcomed, whether positive or negative.
(Anonymous comments are allowed, but comments with URL links or unrelated comments will be removed.)