C++ GUI programming with Qt 3 – Jasmin Blanchette, Mark Summerfield – 1st Edition

Description

Many companies are facing problems with Windows development using traditional Windows tools such as Visual Studio. When they write applications, even just “single platform” applications for Windows, they often have to account for differences between different Windows versions, which adds hassle to development and maintenance. Qt works no matter the Windows versions.

This book provides all the information needed to become a professional Qt developer. The book also covers cross platform GUI programming – programmers can be working on Windows, Linux, or Mac and the book will work for them. This is useful for commercial companies that use Qt, and for companies that are evaluating Qt.

It will also be valuable to the vast number of open source developers who already use Qt since no other book of comparable quality or comprehensiveness is available. This book teaches Qt’s idioms and how to use Qt to best advantage. The book is organized into four parts. The first part introduces the C++ necessary for the effective use of Qt. The second part covers basic Qt, starting with some very short examples, and quickly building up to a complete Graphical User Interface program.

The second part provides coverage of key Qt features including signals. The third and fourth parts cover more advanced and specialized material.

View more


  • Foreword ix
    Preface xi
    Acknowledgments xiii

    A Brief History of Qt xv

    Part I: Basic Qt

    1. Getting Started ............................................... 3
    Hello Qt ..................................................... 3
    Making Connections ......................................... 5
    Using the Reference Documentation .......................... 8
    2. Creating Dialogs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
    Subclassing QDialog . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
    Signals and Slots in Depth . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
    Rapid Dialog Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
    Shape-Changing Dialogs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
    Dynamic Dialogs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
    Built-in Widget and Dialog Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
    3. Creating Main Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
    Subclassing QMainWindow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
    Creating Menus and Toolbars . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
    Implementing the File Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
    Setting Up the Status Bar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
    Using Dialogs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
    Storing Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
    Multiple Documents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
    Splash Screens . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
    v

    4. Implementing Application Functionality . . . . . . . . . . . . . . . . . . . . 69

    The Central Widget . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
    Subclassing QTable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
    Loading and Saving . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
    Implementing the Edit Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
    Implementing the Other Menus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
    Subclassing QTableItem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
    5. Creating Custom Widgets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
    Customizing Qt Widgets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
    Subclassing QWidget . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
    Integrating Custom Widgets with Qt Designer . . . . . . . . . . . . . . . . 108
    Double Buffering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
    Part II: Intermediate Qt
    6. Layout Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135
    Basic Layouts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135
    Splitters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140
    Widget Stacks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144
    Scroll Views . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145
    Dock Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150
    Multiple Document Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
    7. Event Processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163
    Reimplementing Event Handlers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163
    Installing Event Filters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168
    Staying Responsive During Intensive Processing . . . . . . . . . . . . . . 171
    8. 2D and 3D Graphics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175
    Painting with QPainter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175
    Graphics with QCanvas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185
    Printing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198
    Graphics with OpenGL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209
    9. Drag and Drop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215
    Enabling Drag and Drop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215
    Supporting Custom Drag Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 220
    Advanced Clipboard Handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224

    10. Input/Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22710. Input/Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227
    Reading and Writing Binary Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227
    Reading and Writing Text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234
    Handling Files and Directories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237
    Inter-Process Communication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239
    11. Container Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243
    Vectors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243
    Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 247
    Maps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249
    Pointer-Based Containers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 251
    QString and QVariant . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 254
    12. Databases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261
    Connecting and Querying . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261
    Presenting Data in Tabular Form . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266
    Creating Data-Aware Forms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 275
    13. Networking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283
    Using QFtp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283
    Using QHttp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289
    TCP Networking with QSocket . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 291
    UDP Networking with QSocketDevice . . . . . . . . . . . . . . . . . . . . . . . . 301
    14. XML . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 307
    Reading XML with SAX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 307
    Reading XML with DOM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 312
    Writing XML . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 316
    15. Internationalization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 319
    Working with Unicode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 319
    Making Applications Translation-Aware . . . . . . . . . . . . . . . . . . . . . . 323
    Dynamic Language Switching . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 329
    Translating Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 334
    16. Providing Online Help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 339
    Tooltips, Status Tips, and “What’s This?” Help . . . . . . . . . . . . . . . . . 339
    Using QTextBrowser as a Simple Help Engine . . . . . . . . . . . . . . . . 342
    Using Qt Assistant for Powerful Online Help . . . . . . . . . . . . . . . . . . 346

    17. Multithreading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 349
    Working with Threads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 349
    Communicating with the GUI Thread . . . . . . . . . . . . . . . . . . . . . . . . 359
    Using Qt’s Classes in Non-GUI Threads . . . . . . . . . . . . . . . . . . . . . . . 363
    18. Platform-Specific Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 367
    Interfacing with Native APIs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 367
    Using ActiveX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 371
    Session Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 384
    Appendices
    A. Installing Qt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 393
    A Note on Licensing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 393
    Installing Qt/Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 394
    Installing Qt/Mac . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 395
    Installing Qt/X11 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 397
    B. Qt’s Class Hierarchy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 399
    Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .403

  • Citation

Download now C++ GUI programming with Qt 3

Type of file
Language
Download RAR
Download PDF
Pages
File size
Book
English
464 pag.
20 mb

Leave us a comment

No Comments

Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x