Flylib.com

Books Software

 
 
 

Using the Reference Documentation

Using the Reference Documentation

Qt's reference documentation is an essential tool for any Qt developer, since it covers every class and function in Qt. (Qt 3.2 includes over 400 public classes and over 6000 functions.) This book makes use of many Qt classes and functions, but it doesn't mention them all, nor does it provide all the details of those it does mention. To get the most benefit from Qt, you should familiarize yourself with the Qt reference documentation.

Widget Styles

The screenshots we have seen so far have been taken on Windows XP, but Qt applications look native on every supported platform. Qt achieves this by emulating the platform's look and feel, rather than wrapping a particular platform or toolkit's widget set.

Figure 1.7. Styles available everywhere

graphics/01fig07.gif

Qt application users can override the default style by using the -style command-line option. For example, to launch the Age application with Platinum style on Unix, simply type

./age -style=Platinum

on the command line.

Figure 1.8. Platform-specific styles

graphics/01fig08.gif

Unlike the other styles, the Windows XP and Mac styles are only available on their native platforms, since they rely on the platforms' theme engines.


The documentation is available in HTML format in Qt's doc\html directory and can be read using any web browser. You can also use Qt Assistant , the Qt help browser, whose powerful search and indexing features make it quicker and easier to use than a web browser. To launch Qt Assistant , click Qt 3.2.xQt Assistant in the Start menu on Windows, type assistant on the command line on Unix, or double-click assistant in the Mac OS X Finder.

Figure 1.9. Qt's documentation in Qt Assistant

graphics/01fig09.jpg

The links in the "API Reference" section on the home page provide different ways of navigating Qt's classes. The "All Classes" page lists every class in Qt's API. The "Main Classes" page lists only the most commonly used Qt classes. As an exercise, you might want to look up the classes and functions that we have used in this chapter. Note that inherited functions are documented in the base class; for example, QPushButton has no show() function of its own, but it inherits one from its ancestor QWidget . Figure 1.10 shows how the classes we have seen so far relate to each other.

Figure 1.10. Inheritance tree for the Qt classes seen so far

graphics/01fig10.gif

The reference documentation for the current version of Qt and for some earlier versions is available online at http://doc.trolltech.com/. This site also hosts selected articles from Qt Quarterly , the Qt programmers' newsletter sent to all commercial licensees .

Chapter 2. Creating Dialogs

  • Subclassing QDialog

  • Signals and Slots in Depth

  • Rapid Dialog Design

  • Shape-Changing Dialogs

  • Dynamic Dialogs

  • Built-in Widget and Dialog Classes

This chapter will teach you how to create dialog boxes using Qt. They are called dialog boxes, or simply "dialogs", because they provide a means by which users and applications can "talk to" each other.

Dialogs present users with options and choices, and allow them to set the options to their preferred values and to make their choice. Most GUI applications consist of a main window with a menu bar and toolbar, along with dozens of dialogs that complement the main window. It is also possible to create dialog applications that respond directly to the user 's choices by performing the appropriate actions (for example, a calculator application).

We will create our first dialog purely by writing code to show how it is done. Then we will see how to build dialogs using Qt Designer , Qt's visual design tool. Using Qt Designer is a lot faster than hand-coding and makes it simple to test different designs and to change designs later.