Exercise 9: An Application with Menues and Bars
Winter Term 2011/12
Most real-world application contain elements, such as a menus and various bars. This exercise shows how to program this in Qt.
Unit 1: Browse through the Qt class documentation of QMainWindow, and answer the fol- lowing questions:
1. What are the components of a fully-fleshed real-world application?
2. What are the basic methodsQMainWindowprovides for adding such compo- nents?
3. What classes does Qt provide for handling menues and bars?
Unit 2: Preparation: Create a QMainWindow-application that merely contains a label as its central widget. If you like, center the label. But please, do not waste more than 5 minutes on that task as its just optical sugar.
Unit 3: Extensions: Add a few menu points to the application’s menu bar, Then, you should add some entries to the menus you have just created. Furthermore, add some actions to the menu bar as well as to the menus. Compile and run your program. What is the effect of the action objects so far?
Unit 4: Building Connections: To take advantage of actions, they have to be connected to some (useful) slots. As a simple example, replace your central label with a cus- tomized label that provides a public slottrigger(). On slot’s invokation, the label should show up some text for a limited periode of time. After the time has expired, the text should vanish again. Connect the actions’ signals to the label’s slot.
Unit 5: Design: Use separators to optically divide menus from actions in the menu bar and all sub menus. What can be observed?
Have fun, Matthias and Ralf.
1