C++ Application Framework
Qt includes an intuitive API and an intuitive C++ class library with a rich set of application build blocks for C++ development. Qt goes beyond C++ in the areas of inter-object communication and flexibility for advanced GUI development.
Qt Object Model: Going Beyond C++
The standard C++ object model provides very efficient runtime support for the object paradigm, however its static nature is inflexible in some respects. By combining the speed of C++ with the flexibility of the Qt Object Model, Qt provides both runtime efficiency and a high level of flexibility for GUI programming. Qt goes beyond C++ to add the following features:
- A very powerful mechanism for seamless object communication called signals and slots
- Queryable and designable object properties
- Powerful events and event filters
- Contextual string translation for internationalization
- Sophisticated interval driven timers that make it possible to elegantly integrate many tasks in an event-driven GUI
- Hierarchical and queryable object trees that organize object ownership in a natural way
- Guarded pointers (QPointer) that are automatically set to 0 when the referenced object is destroyed
- A dynamic cast that works across library boundaries
Signals and Slots
A common and recurring source of problems and crashes in development of GUIs is the issue of how to communicate between different components. The Qt solution to this problem is the Signals and Slots mechanism, providing a typesafe way of facilitating inter-object communication. The signals and slots mechanism is a central feature of Qt and probably the part that differs most from the features provided by other frameworks. The general concept is illustrated below:
Signals & Slots in Qt
A signal is emitted when a particular event occurs. Qt's widgets have
many predefined signals, but you can always subclass widgets to add your
own signals to them. A slot is a function that is called in reponse to
a particular signal. Qt's widgets have many pre-defined slots, but it
is common practice to subclass widgets and add your own slots so that
you can handle the signals that you are interested in.