Programming with QT by Matthias Kalle Dalheimer, Paperback | Barnes & Noble
Programming with QT

Programming with QT

by Matthias Kalle Dalheimer

Qt is a C++ class library for writing GUI applications that run on UNIX, Windows 95/98, and Windows NT platforms. Qt is much easier to use than the standard Motif toolkit for UNIX systems, but at the same time Qt emulates the look-and-feel of Motif. Best of all, after you have written an application with Qt, all you have to do is recompile it to have a version that


Qt is a C++ class library for writing GUI applications that run on UNIX, Windows 95/98, and Windows NT platforms. Qt is much easier to use than the standard Motif toolkit for UNIX systems, but at the same time Qt emulates the look-and-feel of Motif. Best of all, after you have written an application with Qt, all you have to do is recompile it to have a version that works on Windows systems. Qt also emulates the look-and-feel of Windows, so you can provide all of your users with native-looking interfaces.Platform independence is not the only benefit of Qt. Qt uses an ingenious signal/slot mechanism for connecting user interaction with program functionality, providing an excellent framework for component-based programming. Graphical rendering in Qt is highly optimized due to its use of effective caching mechanisms — rendering in Qt is often faster than with the similar native API. In addition to user interface classes, Qt features portable support for file system access, working with date and time values, and network programming. With Qt, you'll find that you need to write very little, if any, platform-dependent code because Qt already has what you need.Qt is popular with open-source and Linux developers because it can be used for free on UNIX systems for this type of development. For commercial development, you need a license for Qt, which is available from Troll Tech, the developers of Qt. In addition to open-source development, Qt is being used by several major companies and government and international agencies.While programming with Qt is straightforward and feels natural once you get the hang of it, the learning curve can be steep. Qt comes with excellent reference documentation, but beginners often find the included tutorial is not enough to really get started with Qt. That is where this book steps in. Programming with Qt guides you through the steps of writing a Qt application by showing you how to write a simple paint application. It also helps deepen your understanding of the topics with exercises and fully worked out answers. The book presents all of the GUI elements in Qt, along with advice about when and how to use them, so that you can make full use of the toolkit. There's also lots of information for seasoned Qt programmers, including material on advanced 2D transformations, drag-and-drop, and writing custom image file filters.Programming with Qt helps you get the most out of Qt. With it, you'll learn to take full advantage of this powerful, easy-to-use, cross-platform toolkit.

Editorial Reviews

Lou Grinzo

Linux's meteoric rise in both popularity and usage is increasing the demand for solid information for programmers about all aspects of Linux development, as well as cross-platform issues. Programming with Qt, by Matthias Dalheimer, covers a tool that addresses some of the thornier topics in modern GUI programming, cross-platform application frameworks, and widget toolkits. Qt is a product of Troll Tech, and is available for both X Windows and Win32 environments. Dalheimer is a member of the board of directors of the KDE Foundation, and has considerable Qt experience, since the KDE desktop environment for Linux is based on Qt.

In the book's 25 chapters, Dalheimer provides a good overview of the Qt programming model, and presents a solid conceptual framework for any experienced programmer new to Qt. He includes several usage tips and many pieces of thoughtful advice, any one of which could easily be worth the cost of the book in the right circumstances. He also talks about some more advanced topics, such as how to deal with resizable dialogs, especially at a time when large monitors are nearly ubiquitous; portability issues; and even the pros and cons of various approaches to writing a cross-platform widget toolkit like Qt. For readers new to Qt, especially those with a Windows background, this is all useful and enlightening material.

Dalheimer takes you through the expected steps, from the obligatory "Hello, world!" program to dealing with menus, event handling, Qt's layout managers and container classes, graphics and text programming, file handling, focus issues, and interapplication communication. One of the longer chapters covers writing your own Qt widgets, and includes two extended examples that will be useful references for anyone taking on this task. Chapter 9 is one of the strongest parts of the book, in that it covers numerous graphics programming topics, such as palette management, saving and displaying graphics, double buffering, and transformations.

One area the author focuses on throughout the book, and to good effect, is Qt's use of signals and slots. (These are not traditional UNIX IPC signals, but a variation unique to Qt.) This is the technology that notifies specific parts of a program when UI events happen, such as users clicking on a button or an item in a listbox. Every application framework has its own way of performing this "plumbing," and understanding it well enough to get notifications in the right places, forward them effectively, and so on, is critical to using the framework. Dalheimer clearly appreciates this fact, and doesn't just talk about Qt's signals and slots once and then move on, but returns to the topic several times in different contexts.

Experienced programmers might raise an eyebrow over the thought of covering all this material -- an entire application framework and a widget toolkit -- in a mere 361 pages. (Petzold's Programming Windows, easily the standard in this area, is well over twice the page count in its second edition, for example, even if it does cover some topics not in Qt.) This highlights the only serious problem with this book: Its treatment of some topics is conspicuously thin. For example, the discussion of the file open/save dialogs is barely half a page of text (not counting illustrations), yet you will likely spend considerable time with these dialogs in various programs, using them in different ways. This book isn't meant to be a replacement for Troll Tech's reference manual, obviously, but several examples of how to use these dialogs with various options (multiple selection, file must exist, and the like), as well as a discussion of cross-platform issues would have been very welcome. Similarly, there are places where Dalheimer leaves pertinent questions unanswered, such as what the limit is on the number of items that a Qt listbox will handle. (He does advise against putting too many items into a listbox, for human factors reasons, which is clearly good advice, but it's critical for programmers to know what such limits are if they're to avoid exceeding them.)

I was bothered by the number of extremely short chapters. Chapter 13, "Working with Date and Time Values" is less than one page of text, Chapter 18, "Debugging" is not quite two full pages, and "Sample Qt Projects" mentions only two -- KDE and Ortho Vista -- and doesn't provide nearly the insight into real-world usage of Qt for commercial work that I'd hoped for. More serious yet is the book's almost complete avoidance of font and text output issues, something nearly all programmers will have to wrestle with.

These problems certainly don't make this a bad book, but they do make me wish for at least a few hundred more pages of the kind of work that Dalheimer is clearly capable of, to provide the fuller treatment programmers need of Qt at this time. Still, Programming with Qt, combined with the Qt reference material (freely available from the Troll Tech web site), should be enough to get experienced programmers started, while we hold out hope for a more comprehensive second edition.
Electronic Review of Books

Product Details

O'Reilly Media, Incorporated
Publication date:
Product dimensions:
7.06(w) x 9.17(h) x 0.83(d)

Meet the Author

Matthias Kalle Dalheimer is the President & CEO of Klaralvdalens Datakonsult AB, a Sweden-based consultancy specializing in platform-independent software solutions. He is also a founding member of the KDE project and the current president of the KDE foundation. Kalle has written numerous books for O'Reilly, both in English and in his native German, including "Running Linux" and "Programming with Qt". In his spare time, he enjoys cross-country skiing and reading history books. Kalle lives with his wife Tanja and his two sons Jan and Tim in the middle of the forest near Hagfors in the Swedish province of Varmland.

Customer Reviews

Average Review:

Write a Review

and post it to your social network


Most Helpful Customer Reviews

See all customer reviews >