ACCU Home page ACCU Conference Page
Search Contact us ACCU at Flickr ACCU at GitHib ACCU at Facebook ACCU at Linked-in ACCU at Twitter Skip Navigation

Search in Book Reviews

The ACCU passes on review copies of computer books to its members for them to review. The result is a large, high quality collection of book reviews by programmers, for programmers. Currently there are 1949 reviews in the database and more every month.
Search is a simple string search in either book title or book author. The full text search is a search of the text of the review.
    View all alphabetically
Title:
Programming With Qt
Author:
Matthias Kalle Dalheimer
ISBN:
1 56592 588 2
Publisher:
O'Reilly
Pages:
360pp
Price:
£21-95
Reviewer:
Peter Pilgrim
Subject:
unix; user interfaces
Appeared in:
12-1
I bet a lot of you have heard of the phenomenon of Linux, the UNIX clone operating system created by Finnish student, Linus Torvalds. Less of you will have heard of the K Desktop Environment (KDE) a popular windows desktop GUI supplied with almost of all of the Linux Distribution. Even less of you know of the Qt library that is the foundation stone of KDE. Quite frankly many of you will be surprised to know that Qt is a cross platform C++ toolkit class library that works equally well on Linux, commercial Unix, Windows 98 and Windows NT. With such a toolkit you could divorce yourself from Microsoft Foundations Classes and theOpen Group's Motif toolkit and engineer truly cross platform applications.

There is nothing especially new about this gem of an idea; there have been many proprietary (read vendor locked-in) toolkits in the past, especially in the early 1990s. The ones that are virtually extinct were built on top of the native GUI library in a design known as API Layering. They are considered dead as a consequence of having to support the most common denominator of features across their various supported platforms. Every system will have its strengths and weaknesses, that much is true. For example, Windows has its inspired CoolBars and Property Sheets controls. Motif has its typical drag and drop and fully 3D look-and-feel. Other cross- platform toolkits compensated by implementing a certain system's strength on another system that does not have them; API emulation. Qt is quite different because it achieves compatible cross-platform features by GUI emulation. Qt relies on the graphics or drawing primitives that each platform provides to an emulated Windows or Motif. (Java's Swing toolkit uses the same design to provide a pluggable look and feel.)

So now you know what Qt is. Who wrote it and who sells this flexible C++ toolkit? Troll Tech of Norway invented it (http://www.trolltech.no) and Mr. Kalle Dallheimer wrote a window manager called KDE using it. To cut a long story short, Qt was not open-source licensed and as the KDE became very popular this caused an ethical licensing division and conflict of interest between the Red Hat Linux/Free Software Foundation/GNU/GNOME camps and the KDE/Troll Tech camps. The force de majeur was not rested until Troll Tech intelligently licensed the UNIX Qt version as open source world-wide. So is Kalle's book any good? It is very good book if you start developing and understanding Qt (and KDE) applications. If we leave aside the cross-platform ideals then this is very book to have at your side if you have Linux distribution. I think there is no one else better out there, who could write an introductory tutorial book to Qt.

One of the things that has plagued many a cross-platform GUI toolkit is how to handle callbacks in C++. The Kalle's book describes how and why Qt dispenses with callbacks and uses a different technology called slots and signals. For this Qt uses a Meta object compiler (moc) to compile special reserved words into C++ objects. Qt depends on standard C++ features such polymorphism and virtual functions, inheritance, operating overloading and templates for its collection so don't worry. After telling the reader how to compile and install Qt for Unix systems and Windows 95/98 and Windows NT the real introduction begins classically with the ubiquitous hello-world example application using the Qt toolkit.

Thankfully, the book does not swamp your senses with endless tabulation of API listings, but gently refers you to the on-line documentation. There is a lot of code and plenty of good documentation as to what is going on in the source code. The author has sensibly numbered the source code lines and it is clearly typeset and easy on the eye. New modifications and points of interest in the source code are emboldened. The first three chapters take you through the development of the rubber band scribble application. You will learn how to create a Qt application and window, draw graphics primitives, add a menubar and pull down menu, a scrolled view and a context menu. It looks far easier to develop in Qt than MFC, but that's my opinion.

In chapter four you get a guided tour through the simple widgets that are basically your standard label, text entry, button, list and scrolled views, menu bar, and selection widgets. Chapter five guides you through a short tour of Qt dialogue widgets. The next chapter is about geometry; how to build your GUI with the relevant Qt layout managers. The descriptive middle of the book ends with chapter seven, which provides hints and tips on how to design a working user interface.

Those of you who consider yourself higher level advanced C++ developers will take issue with the Qt specific container classes presented in chapter eight, especially if you are now used to the Standard Template Library. Thankfully these containers are C++ class templates. One of more useful classes is QCache and QIntCache that can save you memory free space in a restricted operating environment. The rest of the book deals with progressively more advanced topics. First up are drawing primitives with figures with Qt. The QPainter is quite extensive rendering engine because it supports compound affine 2D transformations and full drawing primitives that translate, rotate, and scale. Chapter nine also describes how to apply view transformations, double buffering and bit-blitting techniques, which is very useful if you write animation. It is a pity that the most of the later chapters are too short, because there could be more complete examples. Having just little snippets of code perhaps leaves just a little bit to be desired. Thankfully the chapter in text validation has a more complete example and description. At this point you really appreciate that Qt is quite an extensive piece of kit, because there is even a Qt class to handle regular expressions. It is really does beat the pants off Java Swing, MFC and Motif when you realise you need never worry about developing a seemingly hard DD/MM/YYYY date validator control again! But alas, this complete example of source code demonstrating the QRegExp is missing.

What would be an application without persistent storage? In chapter eleven we learn about working with files and directories and discover that Qt provides it own abstraction not surprisingly, namely QFile, QFileInfo and QDir. Luckily C++ developers can still read and write data the usual way with the operators>> and<< on abstracted stream classes called QDataStream and QTextStream. Those of you who program with Java will already realise that File System I/O is major weakness in that language, luckily MS DOS and UNIX at least share some characteristics and Qt does try to cover the more sinister areas with the QFileInfo class.

What would be a modern GUI application without inter-application communications? Qt has its own clipboard classes to cut, copy and paste data. Chapter twelve provides a couple of complete examples of using the QClipboard object. A more difficult concept is drag and drop mechanism. Here we need a least several pages of more thorough treatment of the concept, because writing and demonstrating drag and drop is notoriously difficult.

The rest of book covers a lot more of the more advanced parts of Qt development including handling date and time values, writing your custom Qt widgets, focus handling and event signal and slot handling. The final chapters discuss portability, GUI builders, network programming, and using Visual C++ IDE for Qt Programs. Miscellaneous chapters describe how Qt interfaces with other languages and libraries. There is a discussion of using the toolkit with OpenGL for 3D graphics. There is even a description and a working example of Qt extension for Netscape Plugins. The book finishes with a chapter on sample Qt Projects where KDE is the first described. The chapters are quicker and shorter than expected, but the source code is freely available for downloading from O'Reilly's web site (www.oreilly.com). In the later chapters the depth of the advanced topics, how should I say, need more rootstock. There are questions and answers only for the first half of the book. Above all Kalle's book is a good tutorial with strong hints and tips, but definitely not API reference to the Qt library. If you want to learn Qt and likewise KDE programming then this is a great book to start. In the second edition I would expect to see more concise and advanced examples and an API reference.