An Introduction to Design Patterns in C++ with Qt 4. This book can be used as a textbook for teaching C++ and design patterns, with an emphasis on open-source code reuse.
Part I: Introduction to C++ and Qt 4
Chapter 1. C++ Introduction
Section 1.1. Overview of C++
Section 1.2. A Brief History of C++
Section 1.3. Setup: Open-Source Platforms
Section 1.4. Setup: Win32
Section 1.5. C++ First Example
Section 1.6. Input and Output
Section 1.7. Identifiers, Types, and Literals
Section 1.8. C++ Simple Types
Section 1.9. C++ Standard Library Strings
Section 1.10. Streams
Section 1.11. The Keyword const
Section 1.12. Pointers and Memory Access
Section 1.13. const* and *const
Section 1.14. Reference Variables Points of Departure
Review Questions
Chapter 2. Classes
Section 2.1. Structs
Section 2.2. Class Definitions
Section 2.3. Member Access Specifiers
Section 2.4. Encapsulation
Section 2.5. Introduction to UML
Section 2.6. Friends of a Class
Section 2.7. Constructors
Section 2.8. Subobjects
Section 2.9. Destructors
Section 2.10. The Keyword static
Section 2.11. Copy Constructors and Assignment Operators
Section 2.12. Conversions
Section 2.13. const Member Functions
Review Questions
Chapter 3. Introduction to Qt
Section 3.1. Example Project: Using QApplication and QLabel
Section 3.2. Makefile, qmake, and Project Files
Section 3.3. Getting Help Online
Section 3.4. Style Guidelines and Naming Conventions
Section 3.5. The Qt Core Module
Section 3.6. Streams and Dates Points of Departure
Review Questions
Chapter 4. Lists
Section 4.1. Introduction to Containers
Section 4.2. Iterators
Section 4.3. Relationships Points of Departure
Review Questions
Chapter 5. Functions
Section 5.1. Function Declarations
Section 5.2. Overloading Functions
Section 5.3. Optional Arguments
Section 5.4. Operator Overloading
Section 5.5. Parameter Passing by Value
Section 5.6. Parameter Passing by Reference
Section 5.7. References to const
Section 5.8. Function Return Values
Section 5.9. Returning References from Functions
Section 5.10. Overloading on const-ness
Section 5.11. Inline Functions
Section 5.12. Inlining versus Macro Expansion
Review Questions
Chapter 6. Inheritance and Polymorphism
Section 6.1. Simple Derivation
Section 6.2. Derivation with Polymorphism
Section 6.3. Derivation from an Abstract Base Class
Section 6.4. Inheritance Design
Section 6.5. Overloading, Hiding, and Overriding
Section 6.6. Constructors, Destructors, and Copy Assignment Operators
Section 6.7. Processing Command-Line Arguments Points of Departure
Review Questions
Part II: Higher-Level Programming
Chapter 7. Libraries
Section 7.1. Code Containers
Section 7.2. Reusing Other Libraries
Section 7.3. Organizing Libraries: Dependency Management
Section 7.4. Installing Libraries: A Lab Exercise
Section 7.5. Frameworks and Components
Review Questions
Chapter 8. Introduction to Design Patterns
Section 8.1. Iteration and the Visitor Pattern
Review Questions
Chapter 9. QObject
Section 9.1. QObject's Child Managment
Section 9.2. Composite Pattern: Parents and Children
Section 9.3. QApplication and the Event Loop
Section 9.4. Q_OBJECT and moc: A Checklist
Section 9.5. Values and Objects
Section 9.6. tr() and Internationalization Point of Departure
Review Questions
Chapter 10. Generics and Containers
Section 10.1. Generics and Templates
Section 10.2. Containers
Section 10.3. Managed Containers, Composites, and Aggregates
Section 10.4. Implicitly Shared Classes
Section 10.5. Generics, Algorithms, and Operators
Section 10.6. Serializer Pattern
Section 10.7. Sorted Map Example
Review Questions
Chapter 11. Qt GUI Widgets
Section 11.1. Widget Categories
Section 11.2. QMainWindow and QSettings
Section 11.3. Dialogs
Section 11.4. Images and Resources
Section 11.5. Layout of Widgets
Section 11.6. QActions, QMenus, and QMenuBars
Section 11.7. QActions, QToolbars, and QActionGroups
Section 11.8. Regions and QDockWidgets
Section 11.9. Views of a QStringList Points of Departure
Review Questions
Chapter 12. Concurrency
Section 12.1. QProcess and Process Control
Section 12.2. Threads and QThread
Section 12.3. Summary: QProcess and QThread
Review Questions
Chapter 13. Validation and Regular Expressions
Section 13.1. Validators
Section 13.2. Regular Expressions
Section 13.3. Regular Expression Validation
Review Questions
Chapter 14. Parsing XML
Section 14.1. The Qt XML Module
Section 14.2. Event-Driven Parsing
Section 14.3. XML, Tree Structures, and DOM
Review Questions
Chapter 15. Meta Objects, Properties, and Reflective Programming
Section 15.1. Anti-patterns
Section 15.2. QMetaObject: The MetaObject Pattern
Section 15.3. Type Identification and qobject_cast
Section 15.4. Q_PROPERTY Macro: Describing QObject Properties
Section 15.5. QVariant Class: Accessing Properties
Section 15.6. DataObject: An Extension of QObject
Section 15.7. Property Containers: PropsMap
Review Questions
Chapter 16. More Design Patterns
Section 16.1. Creational Patterns
Section 16.2. Serializer Pattern Revisited
Section 16.3. The Façade Pattern Points of Departure
Review Questions
Chapter 17. Models and Views
Section 17.1. M-V-C: What about the Controller?
Section 17.2. Dynamic Form Models
Section 17.3. Qt 4 Models and Views
Section 17.4. Table Models
Section 17.5. Tree Models
Review Questions
Chapter 18. Qt SQL Classes
Section 18.1. Introduction to MySQL
Section 18.2. Queries and Result Sets
Section 18.3. Database Models
Review Questions
Part III: C++ Language Reference
Chapter 19. Types and Expressions
Section 19.1. Operators
Section 19.2. Evaluation of Logical Expressions
Section 19.3. Enumerations
Section 19.4. Signed and Unsigned Integral Types
Section 19.5. Standard Expression Conversions
Section 19.6. Explicit Conversions
Section 19.7. Safer Typecasting Using ANSI C++ Typecasts
Section 19.8. Run-Time Type Identification (RTTI)
Section 19.9. Member Selection Operators Point of Departure
Review Questions
Chapter 20. Scope and Storage Class
Section 20.1. Declarations and Definitions
Section 20.2. Identifier Scope
Section 20.3. Storage Class
Section 20.4. Namespaces
Review Questions
Chapter 21. Statements and Control Structures
Section 21.1. Statements
Section 21.2. Selection Statements
Section 21.3. Iteration
Section 21.4. Exceptions
Review Questions
Chapter 22. Memory Access
Section 22.1. Pointer Pathology
Section 22.2. Further Pointer Pathology with Heap Memory
Section 22.3. Memory Access Summary
Section 22.4. Introduction to Arrays
Section 22.5. Pointer Arithmetic
Section 22.6. Arrays, Functions, and Return Values
Section 22.7. Different Kinds of Arrays
Section 22.8. Valid Pointer Operations
Section 22.9. What Happens If new Fails?
Section 22.10.
Chapter Summary
Review Questions
Chapter 23. Inheritance in Detail
Section 23.1. Virtual Pointers and Virtual Tables
Section 23.2. Polymorphism and virtual Destructors
Section 23.3. Multiple Inheritance Point of Departure
Section 23.4. public, protected, and private Derivation
Review Questions
Chapter 24. Miscellaneous Topics
Section 24.1. Functions with Variable-Length Argument Lists
Section 24.2. Resource Sharing
Part IV: Programming Assignments
Chapter 25. MP3 Jukebox Assignments
Section 25.1. Data Model: Mp3File
Section 25.2. Visitor: Generating Playlists
Section 25.3. Preference: An Enumerated Type
Section 25.4. Reusing id3lib
Section 25.5. PlayListModel Serialization
Section 25.6. Testing Mp3File Related Classes
Section 25.7. Simple Queries and Filters
Section 25.8. Mp3PlayerView
Section 25.9. Models and Views: PlayList
Section 25.10. Source Selector
Section 25.11. Persistent Settings
Section 25.12. Edit Form View for FileTagger
Section 25.13. Database View Points of Departure
Part V: Appendices
Appendix A. C++ Reserved Keywords
Appendix B. Standard Headers
Appendix C. The Development Environment
Section C.1. The Preprocessor: For #including Files
Section C.2. Understanding the Linker
Section C.3. Debugging
Section C.4. Qt Assistant and Designer
Section C.5. Open-Source IDEs and Development Tools
Bibliography
C++ References
Qt References
OOP References
Docbook References
Miscellaneous References
There are many C++ books out there that either teach C++ or teach Qt, but we found that the C++ books use a variety of different programming styles, and they emphasize some topics that we do not use very often with Qt. The Qt books we have seen all assume prior C++ knowledge. This book, by contrast, assumes no C or C++ programming experience, and it covers the language features of C++ that you need to know in order to use Qt 4 classes as early as possible in the examples and assignments. It can be used as a textbook for teaching C++ and design patterns, with an emphasis on open-source code reuse.