In the previous installment of this series, we implemented two very simple example programs, which nevertheless demonstrated quite a few of the core concepts of Qt programming. This month, let’s will take a step back and look at some of the fundamentals of programming with Qt.
In the previous installment of this series, we implemented two very simple example programs, which nevertheless demonstrated quite a few of the core concepts of Qt programming. This month, let’s will take a step back and look at some of the fundamentals of programming with Qt.
The class diagram in Figure One shows the static class structure of some of the more important Qt classes. Most classes ultimately derive from Qt. Qt doesn’t declare any member variables or functions, and contains only a number of public enums (such as DateFormat { TextDate, ISODate, LocalDate }); and since it doesn’t declare any member variables or functions, it merely provides a convenient grouping of the common enums without polluting the global namespace.
Figure One: Part of the Qt class hierarchy
The most important direct descendant of Qt is the QObject class. This common base class provides the necessary infrastructure for Qt’s language extensions. By inheriting from QObject it’s possible for custom objects to integrate seamlessly with Qt’s object model. We’ll investigate how that’s achieved below.
Three important direct subclasses of QObject are QApplication, QWidget, and QCanvas.
Each program that makes use of Qt’s GUI elements must first instantiate exactly one QApplication object, which handles initialization of the underlying windowing system. Instantiation of QApplication also provides the main event…
Please log in to view this content.
Not Yet a Member?
Register with LinuxMagazine.com and get free access to the entire archive, including: