Chapter 10. Qt Class Hierarchy

Table of Contents
Hierarchy
Base classes
Application classes
Widget foundations: QWidget
Basic widgets
Advanced widgets
Layout managers
Dialogs and Standard Dialogs
Qt Utility classes and their Python equivalents

In this chapter I will present an overview of the Qt library, including both gui objects and non-gui objects. While well-designed, Qt is a large library, and the key to effective use is not knowing every class by heart, but rather developing an intuition for what is available and where it is. After an overview of the entire hierarchy I will shortly discuss the base classes, the gui classes and compare the Qt utility classes with their Python equivalents.

Hierarchy

As noted before, Qt consists of a hierarchy of classes derived from a basic QObject class, and a side-show cluster of more independent classes. Classes derived from QObject share some important functionality, namely the power to communicate through signals and slots and to arrange themselves in an ownership hierarchy. There are other odds and ends, such as introspection functionality, which is discussed in the Section called Object and class introspection in Chapter 9.

Figure 10-1. Qt Inheritance Hierarchy (only the most important classes)

Prior to version 3.0, PyQt basically plunked everything except for the OpenGL extension in the qt module. That was the situation when I wrote this book. From PyQt 3.0, the Qt modules Canvas, IconView, Network, OpenGL, SQL, Table, WorkSpace and XML have been put in separate Python modules.

In addition to the inheritance hierarchy, there is an ownership hierarchy, where a window will own, for instance, toolbars, a menubar and a statusbar. If the window is deleted, all child objects will be deleted, too, and if a keypress event arrives for an application, it will traverse the tree until it arrives at the right spot. The ownership hierarchy comes into existence by creating objects with their owner object as parent - see the Section called References and ownership in Chapter 9 about this principle.

Figure 10-2. Object Ownership Hierarchy