Qt
Description
Qt is of significant size, however in order to allow optimizations to build time and memory consumption it has been split into modules:
- QtCore – contains the basic classes and primitives. Provides abstraction for the basic OS services such as file access, IPC, multi-threading, synchronization.
- QtNetwork – provides classes used for network communication.
- QtXml and QtXmlPatterns – enable reading and writing XML.
- QtSql – provides abstraction layer over Database Management Systems (DBMS). Allows connecting to databases such as MySQL, PostgreSQL, Oracle, MS-SQL, IBM DB2, SQLite.
- QtScript – implements support for ECMA JavaScript.
- QtGui – contains classes used to create GUI applications – it’s worth to note that none of the above modules has any dependency on any GUI toolkit.
- QtDeclarative – allows building declarative GUI applications – this is the core of the Qt Quick declarative UI framework.
- QtMultimedia – provides access low-level multimedia streaming classes.
- QtOpenGL – contains platform-independent classes to ease OpenGL rendering.
- QtSvg – implements Scalable Vector Graphics image decoding and display.
- QtWebKit – contains an implementation of the WebKit HTML rendering engine used to display web sites.
Capabilities
- Graphics Acceleration (Open GL/ES)
- 3D
- Webkit
- HTML5
- JavaScript
- JSON
- Multimedia
- QML
- Quick
- SQL db access
- XML parsing
- Thread management
- Network support
- File handling
Used By
- Guide Application
- Service Manager
Uses
- OpenSSL
- Glib
- Gstreamer
- DirectFB
- OpenGL ES
Used in Features
TBD
Interfaces
http://qt-project.org/doc/qt-5.1/
Code
Current Version – 5.1
Change History – see Qt site
Known issues – see Qt site
Signals and slots
One of the most Qt-specific features is the “signal and slots” mechanism, which is used by almost all Qt classes.
The signal and slot mechanism is the Qt equivalent of callbacks, however it is much more powerful. It works by defining two endpoints in classes:
- Signals – represent events that can be emitted by objects.
- Slots – represent methods that serve as callbacks for receiving signals.
Similar to callbacks, signals can carry arguments and their declaration is identical to a class method declaration. Slots willing to receive specific signals must have matching arguments, however Qt allows declaration of slots that have fewer arguments to receive signals with more arguments. In such a case, all excess arguments are ignored. The only requirement is that any non-omitted argument must match the signal declaration. For example:
class Test : public QObject { Q_OBJECT signals: void testSignal(int foo, float bar); public slots: void testSlot1(float bar); // Incompatible slot void testSlot2(int foo, float bar, char* baz); // Incompatible slot void testSlot3(int foo, float bar); // Compatible slot void testSlot4(int foo); // Compatible slot void testSlot5(); // Compatible slot };
Slots are connected to signals at runtime using one of the overloaded QObject::connect() calls. For each connection, one needs to specify the source object, source signal, target object and target slot. Signal to slot connections are a many-to-many relationship. One signal can be connected to many receivers (slots) and at the same time a single slot may be connected to multiple signals (provided that the signal types are compatible).
The signal and slot mechanism is widely used in Qt.
Note: Since signal to slot connections are created at run-time there is no way to determine if connecting signals and slots are compatible during compilation*. In case of incompatible slots the QObject::connect() method will fail to establish the connection and show an error on the application console. For GUI applications such messages can be easily unnoticed.
In case of any unexpected behavior related to signal processing, please check the application console for any errors.
* This problem has been addressed in Qt5, which introduces a new syntax for signal and slot connections based on C++11 features.
More information about Qt signals and slots can be found in the Qt Documentation: Signals and Slots (Qt 4.8) Signals and Slots (Qt 5.0)
Graphics View Framework
The Qt Graphics View Framework provides a means to draw a large number of 2D objects on a scene, which can be later drawn in viewports, possibly with transformations applied (zooming, panning or rotating). Using the Graphics View Framework it is not necessary to handle drawing of a particular scene, such as in canvas object. The Graphics View behaves more like a vector graphics system, where a developer can place objects and set its properties, while the framework takes care of rendering them onto a viewport. A graphics view can also be accelerated using OpenGL.
The core of the Graphics View Framework consists of three classes:
- QGraphicsScene – represents a list of items that will be rendered into a view. Items have various properties that define their placement in the scene such as position, scale or rotation. Items can also can have a hierarchy, which means that an item can contain child items that inherit properties from their parents.
- QGraphicsItem – this class serves as a base class for all graphics view items. Qt defines several built-in classes for the commonly used shapes such as a rectangle, circle, line, text, images or regular Qt controls such as buttons or text boxes.
- QGraphicsView – a class responsible for rendering a scene onto the screen. A graphics view is inherited from a QWidget class, which means that it can be placed on a window together with other controls. Optionally a graphics view can be configured to render onto a OpenGL viewport providing accelerated rendering.
More information about the Graphics View Framework can be found in Qt Documentation: Graphics View Framework (Qt 5.1)
Porting
Qt is developed with portability in mind, therefore no significant porting effort is needed to cross-compile it to a particular platform.
When building Qt one must keep in mind that the RDK mandates certain Qt components will be enabled. This translates directly to the set of options passed to Qt’s configure script. The following options are required:
Option | Description |
-opensource | Chooses the LGPL-licensed version of Qt |
-opengl es2 | Use OpenGL ES2. |
-openssl | Use system OpenSSL. |
-qt-zlib | Use bundled Zlib. |
-qt-libpng | Use bundled libpng. |
-qt-libjpeg | Use bundled libjpeg. |
-qt-freetype | Use bundled Freetype. |
-phonon | Enable Phonon. |
-phonon-backend | Enable Phon backend. |
-glib | Use system glib. |
-gstreamer | Use GStreamer. |
-webkit | Enable Webkit. |
-plugin-gfx-directfb | Enable DirectFB plugin. |
-no-qt3support | Disable Qt3 support. |
-no-libmng | Do not use libmng. |
-no-nis | Do not use NIS. |
-no-cups | Do not use CUPS. |
-no-scripttools | Do not build script tools. |
-no-accessibility | Disable accessibility features. |
-no-sql-db2 | Do not use DB2. |
-no-sql-ibase | Do not use ibase. |
-no-sql-mysql | Do not use MySQL. |
-no-sql-oci | Do not use OCI. |
-no-sql-odbc | Do not use ODBC. |
-no-sql-psql | Do not use Postgresql. |
-no-sql-sqlite | Do not use SQLite. |
-no-sql-sqlite2 | Do not use SQLite2. |
-no-sql-sqlite_symbian | Do not use Symbian SQLite. |
-no-sql-tds | Do not use TDS. |
-no-dbus | Do not use DBus. |
-no-libtiff | Do not use libtiff. |
When cross-compiling it will most likely be necessary to add or edit the make specification (mkspec) file for the target architecture to add platform-specific toolchain paths and any additional compiler and linker flags as well as include directories. The relevant definitions need to be placed in a file named qmake.conf inside the mkspec/qws/<target-tuple>/ directory, where ‘target-tuple’ contains an identifier composed of the target OS, architecture, standard C library and compiler identifications. For example for a Linux target MIPS (little endian) using uCLibc and GCC the identifier will be “linux-mipsel-uclibc-g++”. For an example on the contents of the qmake.conf file please refer to any of the existing platforms already provided with the Qt sources.