An Introduction to Design Patterns in C++ with Qt™, 2nd Edition doc

766 3.1K 1
An Introduction to Design Patterns in C++ with Qt™, 2nd Edition doc

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

ptg7041395 www.it-ebooks.info ptg7041395 An Introduction to Design Patterns in C++ with Qt ™ , 2nd Edition www.it-ebooks.info ptg7041395 O pen Source technology has revolutionized the computing world. From MySQL to the Python programming language, these technologies are in use on many different systems, ranging from proprietary systems, to Linux systems, to traditional UNIX systems, to mainframes. The Prentice Hall Open Source Software Development Series is designed to bring you the best of these Open Source technologies. Not only will you learn how to use them for your projects, but you will learn from them. By seeing real code from real applications, you will learn the best practices of Open Source developers the world over. Visit informit.com/opensourcedev for a complete list of available publications. The Prentice Hall Open Source Software Development Series Arnold Robbins, Series Editor www.it-ebooks.info ptg7041395 An Introduction to Design Patterns in C++ with Qt ™ , 2nd Edition Alan Ezust and Paul Ezust Upper Saddle River, NJ • Boston • Indianapolis • San Francisco New York • Toronto • Montreal • London • Munich • Paris • Madrid Cape Town • Sydney • Tokyo • Singapore • Mexico City www.it-ebooks.info ptg7041395 Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and the publisher was aware of a trademark claim, the designations have been printed with initial capital letters or in all capitals. The authors and publisher have taken care in the preparation of this book, but make no expressed or implied warranty of any kind and assume no responsibility for errors or omissions. No liability is assumed for incidental or consequential damages in connection with or arising out of the use of the information or programs contained herein. The publisher offers excellent discounts on this book when ordered in quantity for bulk purchases or special sales, which may include electronic versions and/or custom covers and content particular to your business, training goals, marketing focus, and branding interests. For more information, please contact: U.S. Corporate and Government Sales (800) 382-3419 corpsales@pearsontechgroup.com For sales outside the United States please contact: International Sales international@pearson.com Visit us on the Web: informit.com/ph Library of Congress Cataloging-in-Publication Data: Ezust, Alan. An introduction to design patterns in C++ with QT / Alan Ezust, Paul Ezust. 2nd ed. p. cm. Includes bibliographical references and index. ISBN 978-0-13-282645-7 (hardback : alk. paper) 1. C++ (Computer program language) 2. Software patterns. 3. Computer software Reusability. I. Ezust, Paul. II. Title. QA76.73.C153E94 2011 005.13’3 dc23 2011018378 Copyright © 2012 Alan and Paul Ezust All rights reserved. Printed in the United States of America. This publication is protected by copyright, and permission must be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. For information regarding permissions, write to: Pearson Education, Inc Rights and Contracts Department 501 Boylston Street, Suite 900 Boston, MA 02116 Fax (617) 671-3447 Tu x i s c r e a t e d b y L a r r y E w i n g , l e w i n g @ i s c . t a m u . e d u , u s i n g G I M P. Qt and the Qt logo are trademarks of Nokia Corporation and/or its subsidiaries in Finland and other countries. ISBN-13: 978-0-132-82645-7 ISBN-10: 0-132-82645-3 Te x t p r i n t ed i n th e Un i t ed S ta t e s on r e cy c l ed p a p er a t C ou r i e r i n We s t f or d , Ma s s a ch u s e t ts . First printing September 2011 Editor-in-Chief: Mark Taub Acquisitions Editor: Debra Williams Cauley Managing Editor: Kristy Hart Project Editor: Jovana San Nicolas-Shirley Copy Editor: Apostrophe Editing Services Indexer: Cheryl Lenser Proofreader: Gill Editorial Services Publishing Coordinator: Kim Boedigheimer Cover Designer: Alan Clements Compositor: Nonie Ratcliff www.it-ebooks.info ptg7041395  i s b o o k i s d e d i c a t e d t o M i r i a m E z u s t , w i t h o u t whom none of our work would have been possible. www.it-ebooks.info ptg7041395 This page intentionally left blank www.it-ebooks.info ptg7041395 vii Foreword xv Preface xix Preface to the Second Edition xxii Acknowledgments xxv About the Authors xxx Part I: Design Patterns and Qt 4 1 Chapter 1: C++ Introduction 3 1.1 Overview of C++ 3 1.2 A Brief History of C++ 4 1.3 C++ First Example 5 1.4 Standard Input and Output 8 1.5 Introduction to Functions 11 1.6 qmake, Project Files, and Makefile 17 1.7 Getting Help Online 24 1.8 Strings 24 1.9 Streams 26 1.10 File Streams 29 1.11 Qt Dialogs for User Input/Output 34 1.12 Identifiers, Types, and Literals 37 1.13 C++ Simple Types 40 1.14 The Keyword const 52 1.15 Pointers and Memory Access 54 Contents www.it-ebooks.info ptg7041395 1.16 Reference Variables 60 1.17 const* and *const 61 1.18 Review Questions 64 Chapter 2: Top of the class 67 2.1 First, There Was struct 67 2.2 Class Definitions 69 2.3 Member Access Specifiers 71 2.4 Encapsulation 74 2.5 Introduction to UML 75 2.6 Friends of a Class 76 2.7 Constructors 77 2.8 Destructors 80 2.9 The Keyword static 81 2.10 Class Declarations and Definitions 86 2.11 Copy Constructors and Assignment Operators 88 2.12 Conversions 92 2.13 const Member Functions 95 2.14 Subobjects 97 2.15 Exercise: Classes 98 2.16 Review Questions 108 Chapter 3: Introduction to Qt 113 3.1 Style Guidelines, Naming Conventions 114 3.2 The Qt Core Module 116 3.3 QtCreator—An IDE for Qt Programming 119 3.4 Exercises: Introduction to Qt 120 3.5 Review Questions 121 Chapter 4: Lists 122 4.1 Introduction to Containers 122 4.2 Iterators 123 4.3 Relationships 129 viii An Introduction to Design Patterns in C++ with Qt™, 2nd Edition www.it-ebooks.info ptg7041395 4.4 Exercise: Relationships 132 4.5 Review Questions 134 Chapter 5: Functions 135 5.1 Overloading Functions 135 5.2 Optional Arguments 138 5.3 Operator Overloading 141 5.4 Parameter Passing by Value 146 5.5 Parameter Passing by Reference 148 5.6 References to const 152 5.7 Function Return Values 154 5.8 Returning References from Functions 154 5.9 Overloading on const 155 5.10 inline Functions 158 5.11 Functions with Variable-Length Argument Lists 162 5.12 Exercise: Encryption 164 5.13 Review Questions 167 Chapter 6: Inheritance and Polymorphism 168 6.1 Simple Derivation 168 6.2 Derivation with Polymorphism 177 6.3 Derivation from an Abstract Base Class 184 6.4 Inheritance Design 189 6.5 Overloading, Hiding, and Overriding 191 6.6 Constructors, Destructors, and Copy Assignment Operators 193 6.7 Processing Command-Line Arguments 198 6.8 Containers 204 6.9 Managed Containers, Composites, and Aggregates 206 6.10 Containers of Pointers 210 6.11 Review Questions 228 Chapter 7: Libraries and Design Patterns 234 7.1 Building and Reusing Libraries 236 7.2 Exercise: Installing Libraries 244 Contents ix www.it-ebooks.info [...]... www.it-ebooks.info xxvi An Introduction to Design Patterns in C++ with Qt, 2nd Edition • • • • • • • • • • • • subversion14 git15 MoinMoin16 Bugzilla17 Apache httpd,18 ant,19 fop20 pidgin21 Python22 ReportLab PyRXP23 QtCreator24 mysql25 GNU Emacs26 Linux,27 gcc,28 gdb29 valgrind30 Thanks to Norman Walsh [docbook] and Bob Stayton [docbookxsl] for developing and documenting a superb system of publishing tools Thanks... from other languages to using Qt and C++ Qt has always focused on trying to provide an intuitive and easy -to- use API set The focus of the framework has always been on helping application developers to get their work done This focus has, however, often led to rather clean implementations of xv www.it-ebooks.info xvi An Introduction to Design Patterns in C++ with Qt™, 2nd Edition certain design patterns. .. bringing together a lot of good brains Thanks to Emily Ezust for wordsmithing skills and for getting us started with Qt in the first place Thanks to the reviewers who provided input and valuable feedback on the text: Johan Thelin, Stephen Dewhurst, Hal Fulton, David Boddie, Andy Shaw, and Jasmin Blanchette Thanks to Matthias Ettrich for the vision and motivation Thanks to the Trolls@Nokia for writing... programs are platform independent (Wintel, Solaris, MacOS, Linux, *nix, etc.) xix www.it-ebooks.info xx An Introduction to Design Patterns in C++ with Qt, 2nd Edition Many of these benefits can be achieved with C++ used with Qt • 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 (Action|Event|Key)Listener... sorting and filtering, cut and paste, and drag and drop The section on threads has been completely rewritten to highlight the advantages of using QtConcurrent algorithms rather than managing the QThreads directly from your code The Dynamic Forms chapter is gone Instead, we show how to design forms manually and with the assistance of QtCreator/Designer, pointing out various techniques of integrating designer... OOP /C++ at a higher level We wanted to provide a substantial introduction to GUI programming using the multiplatform Qt framework and to introduce and use some important design patterns When Qt 4.0 was released, we did some extensive rewriting to accommodate the code-breaking improvements that it introduced We designed this book first as a textbook to be used in a university class, but we did so in an. .. good docs, producing QtCreator, answering questions on the mailing lists, and porting Qt over to mobile devices Thanks to the editorial and production staff at Prentice Hall for their meticulous reading of our book and for helping us to find the errors that were distributed throughout the text Thanks to Chris Craig, Chris Gaal, and the other gurus at ics.com for feedback and technical assistance Thanks... add to the Qt ecosystem in another way as Paul and Alan have done with this excellent new book —Lars Knoll Director of Qt Research and Development www.it-ebooks.info This page intentionally left blank www.it-ebooks.info Preface C++ had been in use for many years before it was standardized in 1989, which makes it a relatively mature language compared to others in popular use today It is an important language... way and included lots of information that can make it useful for readers with a wide range of backgrounds: from those who already program in C or another procedural language and want to learn OO and GUI programming, to those who have no C background but are familiar with Basic, Java, Python, or another programming language and want to learn C++ The first part of the book is aimed at familiarizing all... PART I Design Patterns and Qt www.it-ebooks.info This page intentionally left blank www.it-ebooks.info 1 C++ Introduction In this chapter, the C++ language is introduced Basic concepts such as keywords, literals, identifiers, declarations, native types, and type conversions are defined Some history and evolution are discussed, along with the relationship between C++ and the C language Some Standard . Clipboard and Data Transfer Operations 341 x An Introduction to Design Patterns in C++ with Qt™, 2nd Edition www.it-ebooks.info ptg7041395 10.5 The Command. Robbins, Series Editor www.it-ebooks.info ptg7041395 An Introduction to Design Patterns in C++ with Qt ™ , 2nd Edition Alan Ezust and Paul Ezust Upper

Ngày đăng: 24/03/2014, 01:21

Từ khóa liên quan

Mục lục

  • Contents

  • Foreword

  • Preface

  • Preface to the Second Edition

  • Acknowledgments

  • About the Authors

  • Part I: Design Patterns and Qt 4

    • Chapter 1: C++ Introduction

      • 1.1 Overview of C++

      • 1.2 A Brief History of C++

      • 1.3 C++ First Example

      • 1.4 Standard Input and Output

      • 1.5 Introduction to Functions

      • 1.6 qmake, Project Files, and Makefile

      • 1.7 Getting Help Online

      • 1.8 Strings

      • 1.9 Streams

      • 1.10 File Streams

      • 1.11 Qt Dialogs for User Input/Output

      • 1.12 Identifiers, Types, and Literals

      • 1.13 C++ Simple Types

      • 1.14 The Keyword const

Tài liệu cùng người dùng

Tài liệu liên quan