More Widgets For Our Form

It is time that we get some more widgets onto our form so that we can have an example to run.

First add another check box with the label Extra Cheese—how to do this should be obvious by now.

Next will be the selection of the pizza size. This time, we will do it in a different order and create the button group first. Select the button group tool from the menu (you will find it in the submenu Tools/Containers) or from the toolbar. Draw the button group and give it the title Size. Now select the radio button tool from the menu or the toolbar (see Figure 2-9) and create three radio buttons within the new button group. Label these three radio buttons Junior, Standard, and Family.

Figure 2-9. The radio button icon

To finish the dialog, create two push buttons by selecting the push button tool from the submenu Tools/Buttons or the toolbar (see Figure 2-10) and give them the labels OK and Cancel.

Figure 2-10. The push button icon

Since the form is probably way too big for the few components that we have put onto it, we can resize it with the same feature we used for the check boxes: Click on the background of the form so that no widget is selected, then right-click to open the context menu, and select Adjust Size. The form will now have a nice size that is just large enough to accommodate its contents.

While working on the form, you might want to see how it looks “for real,” without the grid dots, like a real dialog. This can easily be done by pressing Ctrl-T, which will open the dialog in “test mode” (see Figure 2-11). The widget style [1] used is the default style of the system Qt is running on; i.e., Motif style on Unix and Windows style on Windows. If you want to see your dialog in a different style, just select one of the entries in the Preview menu.

Figure 2-11. The test mode

Finally, give the form a name that is more obvious than Form1. Click on the background of the form so that no component on it is selected, then select the name property in the property editor and change it from Form1 to PizzaEntry. This name will also be the class name of your generated source code.

When you are done, the dialog should look more or less like the one in Figure 2-12. Using the File/Save As... menu entry, save it under the name pizza.ui.

Figure 2-12. This is how the first dialog should look


[1] One of Qt's astounding features is that it displays the user interfaces created with it in one of several different widget styles, independent of the platform it runs on.