Programming with Qt: Writing Portable GUI applications on Unix and Win32

Programming with Qt: Writing Portable GUI applications on Unix and Win32

by Matthias Kalle Dalheimer
     
 

View All Available Formats & Editions

The popular open source KDE desktop environment for Unix was built with Qt, a C++ class library for writing GUI applications that run on Unix, Linux, Windows 95/98, Windows 2000, and Windows NT platforms. Qt emulates the look and feel of Motif, but is much easier to use. Best of all, after you have written an application with Qt, all you have to do is recompile it

Overview

The popular open source KDE desktop environment for Unix was built with Qt, a C++ class library for writing GUI applications that run on Unix, Linux, Windows 95/98, Windows 2000, and Windows NT platforms. Qt emulates the look and feel of Motif, but is much easier to use. 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. Qt also emulates the look and feel of Windows, so your users get native-looking interfaces.Platform independence is not the only benefit. Qt is flexible and highly optimized. You'll find that you need to write very little, if any, platform-dependent code because Qt already has what you need. And Qt is free for open source and Linux development.Although 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's whereProgramming with Qt steps in. You'll learn how to program in Qt as the book guides you through the steps of writing a simple paint application. Exercises with fully worked out answers help you deepen your understanding of the topics. The book presents all of the GUI elements in Qt, along with advice about when and how to use them, so you can make full use of the toolkit. For seasoned Qt programmers, there's also lots of information on advanced 2D transformations, drag-and-drop, writing custom image file filters, networking with the new Qt Network Extension, XML processing, Unicode handling, and more.Programming with Qt helps you get the most out of this powerful, easy-to-use, cross-platform toolkit. It's been completely updated for Qt Version 3.0 and includes entirely new information on rich text, Unicode/double byte characters, internationalization, and network programming.

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

ISBN-13:
9781449390938
Publisher:
O'Reilly Media, Incorporated
Publication date:
01/22/2002
Sold by:
Barnes & Noble
Format:
NOOK Book
Pages:
522
File size:
4 MB

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 >