Dialog boxes are important in every GUI-based application. Even simple applications usually have several dialog boxes, and in applications of medium complexity, it is not uncommon to have 50 or more dialog boxes. Therefore, a GUI developer builds dialog boxes often. In this chapter, we look at the facilities Qt provides for building dialog boxes. We start with predefined dialog boxes that cover a well-defined task, which can usually be used out of the box. Afterwards, we look at building blocks you can use to create your own dialog boxes.
Predefined dialog boxes are nice for the stressed developer because you can get good results with very little coding. Often only one line of code will suffice to customize these boxes for your purposes.
Qt currently provides several predefined dialog boxes that are
QColorDialog for selecting a color,
QFileDialog for specifying files and directories,
QFontDialog for selecting a font,
QInputDialog for entering a one-line textual value,
showing progress in lengthy operations,
general messages, and
QErrorMessage for error
messages that the user can select not to show again. We will look at
each of these boxes in turn.
QFileDialog (see Figure 5-1) provides a File Selection dialog
box. It lets
the user choose a file for opening, saving, or other file-related
operations. Most of the time,