Site hosted by Angelfire.com: Build your free website today!

Qt Toolkit and the development tools for Qt

(October, 2000)
 

What is this?

Qt C++ Toolkit is intended for the development of GUI applications. Product developer, Troll Tect AS (Norway), was founded in 1994 and focuses the activity on the development of toolkits, libraries and on providing of consulting services. Qt Toolkit is a Troll Tech's basis product; the development was started in 1992, the first commercial version was issued in 1995. Qt was designed as a multiplatform toolkit allowing a developer to create applications for UNIX and Windows OS family: MS Windows (95/98/NT), Solaris, SunOS, HP-UX, Digital UNIX (OSF/1), Irix, Linux, FreeBSD, BSD/OS, SCO, AIX and so on. A beta-version of Qt for an embedded devices running Linux (QT/Embedded) was issured on the middle of June, 2000.
 

Licence

Qt/Windows and Qt/Embedded are distributed as Professional Edition, Qt/X11 is distributed as Free Edition. Earlier versions of Qt/X11 were being dustributed under the "Qt Free Edition" licence. Qt/X11 version 2.0 and later ones are distributed under the QPL (Qt Public Licence). In opposite to the LGPL, the QPL prohibits to use Free Edition products in the development of commercial products. In this case it's necessary to purchase a Professional Edition version of the product.
 

Qt toolkit features

API. Qt toolkit API contains about 250 C++ classes; some classes are templates. The library includes lots of ready-to-use widgets for professional-looking user interface creating. The library provides widget types listed forth: Since version 2.1 Qt/X11 supports multi-document interface (MDI).

Qt not only supports GUI, but also it hides the "application - OS" interaction. Qt provides platform-independend functions for file system access, time/date access and TCP/IP sockets access.

Drawing Engine. Qt has a platform-independend drawing engine (implemented in class QPainter), which has cashing mechanism for speeding up of a painting process. In Qt/X11 graphical contexts are cashed. Such engine often works faster than programs using X11 functions directly. The library is optimized for fast running and reasonable memory using (Qt/X11 uses Xlib function directly).

Event handling. Superclass of all widget classes (named QWidget) contains virtual functions for mouse and keyboard events handling, which may be overrided in superclasses.

Signals/slots. Object-oriented Qt library provides convenient class reusing, because every object interacts with the outside by "slots" and "signals". This method of interaction provides to any object more of independence of other objects. When the object state have been changed and the object need to note the outside about it, it sends the appropriate signal. Then it proceeds to work not "paying attention" what exactly object will receive the object signal and when. Slot is a class method intended for calling by a signal. A class "doesn't know" what signal calls it's slot. Any Qt object has a signal set and a slot set. Signals and slots of an object or different objects are connected each to other by a special function (QObject:: connect()) inherited from superclass QObject. So, objects live independently, and they don't "know" what objects are connected to their signals and slots at any moment. It's allowed to connect any number of signals to the same slot and vice versa. Signals and slots are not more slowlier than an ordinary function calling.
Slot/signal mechanism is a convenient alternative to callback functions. Besides, this mechanism is attractive for the model-view-controller design (MVC). C++ code necessary for a slots and signals handling is generated by the special compiler moc (Meta Object Compiler) on the basis of a header file.
The library supports creating of applications which is convenient for internationalization. Internationalization is performed with string translation tables. Translation table contains the pairs of the corresponding strings on the different languages. Qt provides a full support of the 16-bit code table Unicode.

Flickering is a problem of any GUI toolkit. Flickering gets visible while several repainting operations occur sequentially. Qt solves this problem using buffering. At the beggining, all necessary repainting operations are performed in the memory area contained the screen pixel map (pixmap). Then the buffer contents is painted on a screen by the only fast repainting operation. Sometimes a part of a screen is painted. So, the most effective way to repaint is chosen from time to time.

Fonts. Qt uses the fonts available in X Window. A font is defined by its attributes. In cases when described font is unavailable, Qt uses the most matched to one. Qt contains the special class (QFont) to describe a font.

Widget styles. The library supports widget styles (sets of features, which define the GUI look and feel). Style can be changed to other one at run time.
Qt provides the following styles: Motif, CDE, Windows, Platinum and other.

Documentation. Documentation is available as man-pages and as a Postscript text.
The product contains programming examples "step-by-step" for newbies. There is on-line reference on the company's site.
 

Development tools

All of the products described here are destributed under the GPL.
 

Qt Architect 2.0

Qt Architect is a visual tool for dialog development with using of Qt library classes. Dialog final form is C++ code.

Dialog development

Qt Architect has the same user interface as other GUI toolkits: the main window is used for dialog creating, dialog and widget properties are placed to the special window (fig.1, 2). So, let's consider the specifical features of Qt Architect.
Qt Architect allows a developer to connect signals of dialog widgets to slots of the class "dialog data" (see "C++ code generating"). While this connecting is performed, a new slot is created with arguments of types like signal arguments are of. Unfortunately, Qt Architect allows only to connect the slots and the signals mentioned above. So, you will connect slots and signals of different objects or different dialogs only in C++ code "manually".


Figure 1

qtarch2
Figure 2

For positioning of widgets inside of a dialog a developer can use layouts. Sizes of widgets inside of a layout are corrected every time layout size is changed. As the first step, the whole dialog layout are created, as the next steps, you include to the "main" layout other layouts, spacers or widgets. The latters are included to a layout from the list of widgets placed in the dialog. After including to a layout, the widget disappeares from the list. (fig 3.)

qtarch3
Figure 3

Layouts are of types:

Qt Architect allows to perform the following operations with a widget group: aligning to one of the margins (right, left, top, borrow), setting equal horizontal or vertical sizes for all widgets in a group.
Qt Architect supports internationalization; the former can be forced to use function QObject::tr() during code generating. tr() translates a string to the other language.
Qt Architect allows only to setup the known widget properties, but not to add or to delete the latters. If you need to use new properties you need use third-party or your own widgets.

Additional widgets are included in Qt Architect as "modules" (shared object files). Modules implement the functions, which allow Qt Architect to use custom widgets for dialog development, that is to set up properties values, to save the widgets in dialogs, to generate C++ code implementing the wigdets, and so on.
How to create your own modules is described into documentation. Documentation also advaces to use the source codes of the widgets included into Qt Architect. Additing of a new widget is performed by means of Qt Architect setting up.

Documentation on using of Qt Architect is available in Postscript format; documentation on the widgets properties is available in HTML format.

Creating of images

Qt Architect contains the pixel image editor. It's used for creating of an images used only by Qt Architect. After drawing, image is saved in BMP format file. Besides, the header file and the C++ code file describing the image are created. (fig 4.)

qtarch4
Figure 4

C++ code generating

Qt Architect saves dialogs in .gld files (internal format). When a dialog is fully developed, it's necessary to fulfil C++ code generating on the basis of the dlg-file.
Generating includes executing of the two steps:

Qt Designer (in package Qt 2.2.0-beta)

Qt Designer is a visual tool for dialog development using Qt library classes. A dialog final form is C++ code.

Dialog development

Qt Designer has user interface similar to interface of other GUI toolkits. (fig. 5.)

qtdes1
Figure 5

So, let's consider the specific features of the product.
Dialog development includes not only widget arranging in a dialog, but also connecting slots and signals of the widgets. Unfortunately, Qt Designer allows to connect slots and signals of the same dialog. Connecting of slots and signals of different widgets is performed in C++ code. Qt Designer allows a developer to view the full list of connections for all dialog widgets. Layout managment is different than one in Qt Architect.

In Qt Designer layouts are built another way. As the first step, you mark some widgets (that is you incorporate them in the group), and as the second step, you mark this group as the layout of required type:

Sizes of widgets inside of the layout are corrected every time layout size is changed. Layouts can contain other layouts. (fig. 6.)

qtdes2
Figure 6

So, a widget group allows to incorporate widgets into a layout, and group can be moved inside of a dialog. Qt Designer supports internationalization: during C++ code generating it uses function Object::tr() for translating of string to a target language.

Qt Designer can use third-party or your own widgets for dialog developing on condition that these widgets are described in XML format and are saved in a file with .cw extention. This file contains the specific features, the slots, the signals, header file name and other data of the new widget. Qt Designer will show common widgets features in the properties window automatically. Qt Designer transfers data from a .cw file into a dialog file. Because of Qt Designer is not informed how to show custom widgets, it shows the latter as icon.
Tab order setting up is fulfilled simply and convenient in special mode. All of dialog widgets are marked by number mark according to an initial tab select order. This order is changed by mouse clicking to number marks on widgets in the necessary order. (fig. 7.)

qtdes3
Figure 7

A dialog can be shown in various styles: Motif, CDE, Windows, Platinum and other. Dialog preview is performed immediately (it doesn't need in the dialog compiling).

Other the useful features of Qt Designer:

Qt Designer has comprehensive documentation on using and on the Qt library.

qtdes4
Figure 8

C++ code generating

C++ code generating is performed by the user interface compiler (uic). It is not included into the development enviroment, so you can use compilers for other programming languages instead. Besides, dialogs saved in XML format you can edit by other instruments.
 

KDevelop 1.1

KDevelop is an integrated development enviroment allowing to use compiler, linker, autoconf and configure utilites. KDevelop uses the embedded debugger, but you can force it to use the external ones. Kdbg is a default external debugger. Besides, the environment has the enought mature embedded text editor with syntax highlightning (KWrite) (Fig 9, 10). You can include additional items in menu "Tools" to run utilities farther.

kdev1
Figure 9

kdev2
Figure 10

KDevelop has the embedded editor for WYSIWYG creating of dialogs. The editor is not enoght mature: it provides a few quantity of widgets (of Qt and KDE), it doesn't provide widget layouts and widget group operations. KDevelop saves dialogs in files of internal format and then generates C++ code choosing the class mentioned in generating options as the superclass.

Application generating

KDevelop has the application templates generator, which can create some types of KDE applications (Mini-, Normal-, Normal-OpenGL, ...), some types of Qt applications (Normal-, SDI, MDI, ...), terminal applications (C, C++) and a customer application. CVS support may be included in a project. (fig. 11)
It supports application internationalization. It is provided by the additing to a project of a file with messages on different languages.

kdev3
Figure 11

Classes

KDevelop has qtdes4
Figure 12

File managment

KDevelop has File Manager which provides two modes of directory viewing. The first mode is when File Manager shows the real directory structure (tab named "RFV", that is Real File Viewer). The second mode is when File Manager shows files grouped in accordance with their contents: header files, sources files, dialogs and so on (tab named "LFV", that is Logical File Viewer) (fig. 13).

kdev5
Figure 13

File Manager allows to manipulate files: to remove them from disk, to include them to a project or to remove them from a project. If a project uses CVS, it's allowed to perform the following operations with the project files: Update, Commit, Remove from Repository, Add to Repository.

Documentation

kdev6
Figure 14

KDevelop has the embedded documentation browser. Documentation is shown in the shape of "tree". The browser contains documentation on Qt liblary, KDE library, on KDevelop and on a current project.
KDevelop allows to create the User Handbook in SGML format and to generate one in HTML format. The environment allows to generate HTML documentation on a project API with links to the used libraries. (fig. 14) KDevelop has the help system, providing Hints, "What's this?" and hints in status bar.