Book review: An Introduction to Design Patterns in C++ with Qt4

Contrary to what the title may hint to, this book is an introduction to C++ and the Qt library. And in the process, the authors tried to teach some good practices through design patterns. So if you’re a good C++ or Qt programer, this book is not for you. If you’re a beginner, the answer is in my review.

Content and opinions

The first part is an introduction to C++ and Qt4. How to install and compile Qt, Basic types and operators are explained, as well as small other things. First red alert, using namespace std; is written in some headers, one bad point for good practices… Then objects are presented with classes (a yellow warning, some things are not correct, struct can be used to declare a class, and there is no need for a member access specifier) before the first short Qt chapter. It was very short, but one cannot explain Qt without some C++ lugagge, so this was to be expected. Strangely, lists were dealt with next and then functions. Well, why not. Finally, the part ends with polymorphism and inheritance. If the chapter is globally OK, there are some big red alerts when I read it. For instance, in their example, Square inherits from Rectangle, Ellipsis from Circle… This is not good practice at all. Square IS NOT A Rectangle. This is well explained in a lot of tutorials and books, and it should never be written as an example in a book about good C++ and Qt practice.

On a side note, some terms are used before their definitions… in the last part. So the organization of that part was not the best one.

The second part deals with Qt itself (there is still no complete C++ presentation…). After some reuse speach, design patterns are introduced. Well, there is only one in the chapter, so this chapter has only one section (surprising when you read the content of that chapter). The Qt core class QObject has a whole chapter, but there are some mistakes and some missing explanations. First with signal and slots, slots can be called directly, as well as signals (for the moment). And with the normal way of signaling, there is no thread waiting for another, it’s just a “stupid” function call (the authors claim that the signal blocks the thread until the slot is executed, but the slot runs in the same thread, so this is not possible). And finally, there are no correct explanation of the Q_OBJECT macro. The remaining of this part is OK (compared to what I’ve said before, it only means that I didn’t find something as big), going from containers to widgets, XML, regular expressions, but also concurrency. Other design patterns are presented in several chapters.

The third chapter should have been the second one, it’s a C++ reference beginning with C++ type mecanisms (types themselves, casts, …), scope and namespaces (at last), what is a statement and control structures (how is it possible to make an introduction to a language and talk about those important pieces of the language in the last chapter ??), exceptions (not that well explained, like for exception specification, the authors should read some of Herb Sutter’s books), memory handling (memory leaks, segmentation faults, …) and finally how does inheritance work.

Oh, I forgot, a macro does not have a namespace, macros are managed by the preprocessor. I think the authors meant “functions” instead.


Sadly, the book missed its main goal, introducing novices to C++ and Qt and teach them good coding practices. They would be better with a good C++ book and the Qt4 book.

2 thoughts on “Book review: An Introduction to Design Patterns in C++ with Qt4

  1. I am trying hard as hell to try and understand this book. I have studied C++ programming last semester and am not using it every day. So the concepts are still a bit hard. I have a really hard time with this book as I can not see where it is going and what it is trying to teach me. The examples are poorly explained for a beginner like me. The tutorial that I have received also keeps correcting the book, this should have been like this, or don’t know why the author have done this….. then also try and re-write the example and see if you can get it to work…Arent I suppose to learn from the examples..if I was in the position of correcting the examples why would I be studying this book?

    Isn’t there another book that I could refer to that could possibly shed some light?

    1. There are plenty 😉 I can suggest Accelerated C++. I didn’t read it yet, but I’ve heard only excellent critics on it.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.