Uh-oh, it looks like your Internet Explorer is out of date.

For a better shopping experience, please upgrade now.

Introduction to Design Patterns in C++ with Qt

Introduction to Design Patterns in C++ with Qt

2.6 3
by Alan Ezust

See All Formats & Editions

Master C++ “The Qt Way” with Modern Design Patterns and Efficient Reuse

This fully updated, classroom-tested book teaches C++ “The Qt Way,” emphasizing design patterns and efficient reuse. Readers will master both the C++ language and Qt libraries, as they learn to develop maintainable software with well-defined code


Master C++ “The Qt Way” with Modern Design Patterns and Efficient Reuse

This fully updated, classroom-tested book teaches C++ “The Qt Way,” emphasizing design patterns and efficient reuse. Readers will master both the C++ language and Qt libraries, as they learn to develop maintainable software with well-defined code layers and simple, reusable classes and functions.

Every chapter of this edition has been improved with new content, better organization, or both. Readers will find extensively revised coverage of QObjects, Reflection, Widgets, Main Windows, Models and Views, Databases, Multi-Threaded Programming, and Reflection. This edition introduces the powerful new Qt Creator IDE; presents new multimedia APIs; and offers extended coverage of Qt Designer and C++ Integration. It has been

restructured to help readers start writing software immediately and write robust, effective software sooner.

The authors introduce several new design patterns, add many quiz questions and labs, and present more efficient solutions relying on new Qt features and best practices. They also provide an up-to-date C++ reference section and a complete application case study.

  • Master C++ keywords, literals, identifiers, declarations, types, and type conversions.
  • Understand classes and objects, organize them, and describe their interrelationships.
  • Learn consistent programming style and naming rules.
  • Use lists, functions, and other essential techniques.
  • Define inheritance relationships to share code and promote reuse.
  • Learn how code libraries are designed, built, and reused.
  • Work with QObject, the base class underlying much of Qt.
  • Build graphical user interfaces with Qt widgets.
  • Use templates to write generic functions and classes.
  • Master advanced reflective programming techniques.
  • Use the Model-View framework to cleanly separate data and GUI classes.
  • Validate input using regular expressions and other techniques.
  • Parse XML data with SAX, DOM, and QXmlStreamReader.
  • Master today’s most valuable creational and structural design patterns.
  • Create, use, monitor, and debug processes and threads.
  • Access databases with Qt’s SQL classes.
  • Manage memory reliably and efficiently.
  • Understand how to effectively manage QThreads and use QtConcurrent algorithms.

Click here to obtain supplementary materials for this book.

Editorial Reviews

The Barnes & Noble Review
Using Qt 4, developers can build optimized cross-platform applications that target Windows, Macintosh, and Linux from a single C++ code base. That's a remarkable promise. But the effectiveness and performance of your applications depends on how you create them. Fortunately, best-practice design patterns exist. This book delivers them.

Alan and Paul Ezust assume minimal upfront experience, so you can use this book whether you're new to Qt 4, to C++, or to design patterns. They show you how to make the most of language and platform features like classes, lists, and functions. They present style guidelines and naming conventions your entire programming team can adopt. Best of all, they introduce higher-level modular programming techniques for serious production development: QObject, generics, containers, GUI widgets, concurrency, and more. From validation to XML, serialization to models and views, it's here: all you need to do cross-platform Qt development right. Bill Camarda, from the December 2006 Read Only

Product Details

Pearson Education
Publication date:
Prentice Hall Open Source Software Development Series
Sold by:
Barnes & Noble
File size:
24 MB
This product may take a few minutes to download.

Related Subjects

Read an Excerpt

C++ had been in use for many years before it was standardized in 1989, which makes it a relatively mature language compared to others that are in popular use today. It is a very important language for building fast, efficient, mission-critical systems. C++ is also one of the most flexible languages around, giving developers many choices of programming styles for use in high-level GUI code as well as low-level device drivers.

For a few years in the early '90s, C++ was the most popular object-oriented (OO) language in use, and many computer science (CS) students were introduced to object-oriented programming (OOP) via C++. This was because C++ provided a relatively easy transition to OOP for C programmers, and many CS professors had been teaching C previously.

Starting around 1996, Java gained favor over C++ as the first OO language for students to learn. There are a number of reasons that Java gained so much popularity.

  • The language itself is simpler than C++.
  • The language has built-in garbage collection, so programmers do not need to concern themselves with memory de-allocation.
  • A standard set of GUI classes is included in the development kit.
  • The built-in String class supports Unicode.
  • Multithreading is built into the language.
  • It is easier to build and "plug in" Java Archives (JARs) than it is to recompile and relink libraries.
  • Many Web servers provide Java APIs for easy integration.
  • Java programs are platform independent (Wintel, Solaris, MacOS, Linux, *nix, etc.).

Many of Java's benefits listed above can be achieved with C++ used in conjunction with Qt 4.

Qt provides a comprehensive set of GUI classes that run faster, look better,and are more flexible than Java's Swing classes.Signals and slots are easier to use than (ActionEventKey)Listener interfaces in Java.

Qt 4 has a plugin architecture that makes it possible to load code into an application without recompiling or relinking.Qt 4 provides foreach, which makes iteration through collections simpler to read and write.

Although Qt does not provide garbage collection, there are a variety of alternatives one can use to avoid the need to delete heap objects directly.

  1. Containers (see Section 10.2)
  2. Parents and children (see Section 9.2)
  3. auto_ptr (see Section 16.3.2)
  4. QPointer (see Section 19.9).
  5. Subobjects (see Section 2.8)
  6. Stack objects (see Section 20.3)

Using C++ with Qt comes very close to Java in ease of use, comprehensiveness, and convenience. It significantly exceeds Java in the areas of speed and efficiency, making everything from processing-intensive server applications to high-speed graphics-intensive games possible.

Another benefit of learning C++ with Qt comes from Qt's widespread use in open-source projects. There is already a great wealth of free open-source code that you can learn from, reuse, and perhaps help to improve.How to Use This Book

Part I contains an introduction to C++, UML, and the Qt core. This part is designed to avoid forward referencing as much as possible, and it presents the topics in an order and a level of detail that should not overwhelm someone who is new to C/C++.

In Part II, you will find higher-level programming ideas, Qt modules, and design patterns. Here we present paradigm-shifting ways of writing code and organizing objects in a modular fashion.

For completeness and for reference, Part III covers in more depth some of the "dry" but important C++ features that were introduced in Part I. By the time the reader has reached this point, these ideas should be a lot easier to understand.At the end of each chapter, you will find exercises and review questions. Most of the programming exercises have solutions available on our Web site. For the questions, if the answers are not in the preceding chapter, then often there are pointers on where to find them. If this book is used for a course, these questions could be asked by the student or by the teacher, in the classroom or on an exam.

Source code files for all the examples in this book are contained in the file src.tar.gz, which can be downloaded from http://oop.mcs.suffolk.edu/dist.A Note about Formats and Book Production

What you are reading now is only one of a number of possible versions of this text available. Because the document was originally written in

Each programming example is extracted from working source code. The Web version provides a hyperlink from each code excerpt to its full source file. This makes it very easy to try the examples yourself. The text and listings in the Web version also contain hyperlinks from each library ClassName to its class documentation page.

We wrote the original manuscript using jEdit and gnu-emacs, marking it up with a modified DocBook/

The cover photo is of the Panama Canal. Before there was a Panama Canal, ships had to travel down and then up the entire length of South America to get from one coast of the United States to the other. The canal provided a much shorter and more direct path. The aim of this book is to provide a shorter and more direct path for programmers who don't have a lot of extra time and who need to obtain working mastery of C++ OOP and design patterns. Qt 4 makes this possible.Style Conventions

Monospace—used for any literal symbol that appears in the code listings

Bold—used the first time a term appears (key terms, defined terms, etc.)

Italic—used for emphasis, and also used for wildcards (terms that need to be replaced by "real types" when they are actually used). In monospace text, these terms are set italic and monospace.

Meet the Author

Alan Ezust received his M.Sc in computer science from McGill University in Montreal. He currently works as a Nokia Certifi ed Qt Specialist for ICS (www.ics.com), a company that specializes in delivering training and professional services onQt software. He honed his teaching and courseware development skills at Learnix, and later at Objectivity, where he taught and/or wrote courses in Python, UNIX, C, C++, Java, Perl, Design Patterns, Froglogic Squish, and Object Oriented Databases. He lives in Victoria, BC, Canada.


Paul Ezust (Cambridge, Massachusetts) chaired Suffolk University’s Department of Mathematics and Computer Science for more than 30 years, leading development of computer science curricula based on Association for Computing Machinery guidelines. He has done extensive outside consulting, contract programming, and research in computational mathematics.

Customer Reviews

Average Review:

Post to your social network


Most Helpful Customer Reviews

See all customer reviews

An Introduction to Design Patterns in C++ with Qt 2.7 out of 5 based on 0 ratings. 3 reviews.
Anonymous More than 1 year ago
Anonymous More than 1 year ago
First off the extensive use of [ . . . . ] which appears to mean 'you figure this part out' is annoying, followed by examples that are almost identical to the built-in reference material. The two sections I tried to reference from this book so far ( both of which I can do in QT 3.3) have examples that do not work as illustrated. Accessing a database didn't work until I put 'sql' in the .pro file. I can't get the Model example to work. I have 12 years experience with QT 3.3 so I'm not a novice, but I believe a book called 'Introduction to....' should start at the basic level and build on the basics.
Gimpit More than 1 year ago
Alan Ezust has done it again. Alan is a great instructor and it shows in this book. He has broken the fairly steep learning curve of Qt and C++ into navigable pieces. I think this is by far the first book that teaches Qt and C++ in depth without leaving the reader to wonder how "this function or this module does what it does." After reading this book you will understand Qt with enough understanding to write your own programs without question.