Programming with Qt, 2nd Edition

Book description

The popular open source KDE desktop environment for Unix was built with Qt, a C++ class library for writing GUI applications that run on Unix, Linux, Windows 95/98, Windows 2000, and Windows NT platforms. Qt emulates the look and feel of Motif, but is much easier to use. Best of all, after you have written an application with Qt, all you have to do is recompile it to have a version that works on Windows. Qt also emulates the look and feel of Windows, so your users get native-looking interfaces. Platform independence is not the only benefit. Qt is flexible and highly optimized. You'll find that you need to write very little, if any, platform-dependent code because Qt already has what you need. And Qt is free for open source and Linux development. Although programming with Qt is straightforward and feels natural once you get the hang of it, the learning curve can be steep. Qt comes with excellent reference documentation, but beginners often find the included tutorial is not enough to really get started with Qt. That's where Programming with Qt steps in. You'll learn how to program in Qt as the book guides you through the steps of writing a simple paint application. Exercises with fully worked out answers help you deepen your understanding of the topics. The book presents all of the GUI elements in Qt, along with advice about when and how to use them, so you can make full use of the toolkit. For seasoned Qt programmers, there's also lots of information on advanced 2D transformations, drag-and-drop, writing custom image file filters, networking with the new Qt Network Extension, XML processing, Unicode handling, and more. Programming with Qt helps you get the most out of this powerful, easy-to-use, cross-platform toolkit. It's been completely updated for Qt Version 3.0 and includes entirely new information on rich text, Unicode/double byte characters, internationalization, and network programming.

Publisher resources

View/Submit Errata

Table of contents

  1. Special Upgrade Offer
  2. A Note Regarding Supplemental Files
  3. Preface
    1. A Productive Weekend
    2. What You Should Know
    3. Organization of This Book
    4. Conventions Used in This Book
    5. Comments and Questions
    6. Acknowledgments
  4. 1. Introduction
    1. Why GUI Toolkits?
    2. Why Portability?
    3. Why Qt?
    4. Implementing Cross-Platform GUI Libraries
      1. API Layering
      2. API Emulation
      3. GUI Emulation
    5. Acquiring Qt
      1. Qt Editions
      2. How Free Is Qt?
    6. Compiling and Installing Qt
      1. Installing Qt or Qt/Embedded on Unix or MacOS X systems
      2. Compiling and Installing Qt on Windows
    7. C++ as Used by Qt
    8. Getting Help
  5. 2. First Steps in Qt Programming
    1. Hello, world!
      1. Exercises
    2. Using the Qt Reference Documentation
      1. Exercises
    3. Adding an Exit Button
      1. Exercises
    4. Introduction to Signals and Slots
      1. The Problem of Callback Functions
      2. A New Approach
      3. Signals and Slots in Qt
      4. Another Example of Signals and Slots
      5. Running moc
      6. Exercises
    5. Event Handling and Simple Drawings with QPainter
      1. Exercises
  6. 3. Learning More About Qt
    1. Adding Menus
      1. Exercises
    2. Adding a Scrolled View
      1. Exercises
    3. Adding a Context Menu
      1. Exercise
    4. File I/O
      1. Exercises
  7. 4. A Guided Tour Through the Simple Widgets
    1. General Widget Parameters
    2. Widget Styles
    3. Buttons
      1. Push Buttons
      2. Radio Buttons and Checkboxes
    4. Selection Widgets
      1. List Boxes
      2. Combo Boxes
    5. Widgets for Bounded-Range Input
      1. Sliders
      2. Dials
      3. Spin Boxes
      4. Widgets for Entering Date and Time
    6. Scrollbars
    7. Menu-Related Widgets
    8. Arrangers
      1. Frames
      2. Group Boxes
      3. Splitters
      4. Widget Stacks
      5. Size Grips
    9. Tab-Related Widgets
    10. Text-Entry Fields
    11. Labels
      1. Simple Labels
      2. QLCDNumber
    12. Widgets for the Office
      1. The Main Window
      2. Toolbars
      3. Status Bars
      4. Multiple Document Interface (MDI)
      5. Docking Windows
      6. Tooltips and “What’s This” Windows
    13. Progress Bars
    14. Scrolled Views
    15. List Views
    16. Icon Views
    17. Widgets for Tabular Material
    18. Widgets for Displaying Rich Text
  8. 5. A Guided Tour Through the Qt Dialog Boxes
    1. Predefined Dialog Boxes
      1. File Selection Dialog Boxes
      2. Color Dialog Boxes
      3. Font Dialog Boxes
      4. Message Boxes
      5. Input Dialog Boxes
      6. Progress Dialog Boxes
      7. Error Message Dialog Boxes
    2. Building Blocks for Your Own Dialog Boxes
      1. Tab Dialog Boxes
      2. Wizards
  9. 6. Using Layout Managers
    1. Layout Manager Basics
    2. Laying Out Widgets in Rows and Columns
    3. Nested Layout Managers
    4. Grid Layout
    5. Implicit Geometry Management
  10. 7. Some Thoughts on GUI Design
  11. 8. Container Classes
    1. Available Container Classes
    2. Choosing a Container Class
    3. Working with Reference-Based Container Classes
      1. Basic Usage
      2. Caching Data
      3. Iterators
      4. Stacks and Queues
    4. Working with Value-Based Container Classes
  12. 9. Graphics
    1. Animations
    2. Printing
    3. Managing Colors
      1. Color Allocation
      2. Color Models
      3. Color Groups and Palettes
    4. Basic QPainter: Drawing Figures
      1. Selecting Brushes, Colors, and Pens
      2. Drawing Operations in QPainter
    5. Advanced QPainter
      1. Two-Dimensional Transformations
      2. View Transformations
      3. Clipping
    6. Double-Buffering and Other Nifty Techniques
    7. Independently Movable Objects with QCanvas
      1. Adding Different Items to the Canvas
    8. Working with Styles
    9. Loading and Saving Custom Image Formats
    10. Setting a Cursor
  13. 10. Text Processing
    1. Internationalization and Localization of On-Screen Text
      1. Internationalizing a Qt Application
      2. Localizing Your Application
    2. Validating User Input
    3. Working with Regular Expressions
    4. Reading and Writing XML Files
      1. Processing XML with SAX
      2. Processing XML with DOM
    5. Rich Text
  14. 11. Working with Files and Directories
    1. Reading a Text File
    2. Traversing a Directory
    3. File Information
    4. Reading and Writing Configuration Data
  15. 12. Interapplication Communication
    1. Using the Clipboard
    2. Drag-and-Drop
  16. 13. Interfacing with the Operating System
    1. Working with Date and Time Values
    2. Loading Code Libraries Dynamically
    3. Spawning Child Processes
    4. Playing Sounds
  17. 14. Writing Your Own Widgets
    1. Implementing a Coordinate Selector
    2. Implementing a Browse Box
  18. 15. Focus Handling
  19. 16. Advanced Event Handling
    1. Event Filters
    2. Sending Synthetic Events
  20. 17. Advanced Signals and Slots
    1. Signals and Slots Revisited
    2. Connecting Several Buttons to One Slot
    3. Actions
  21. 18. Providing Help
  22. 19. Accessing Databases
    1. Installation of the SQL Module
    2. Connecting to a Database
    3. Simple Data Retrieval
    4. Data Retrieval with Cursors
    5. Data Display
    6. Data Manipulation
    7. Anything Else?
      1. Metadata
      2. Transactions
      3. More Features
  23. 20. Multithreading
    1. Configuring Qt for Multithreading
    2. Using Qt’s Multithreading Classes
    3. Multithreading Pitfalls
    4. Alternatives to Multithreading
  24. 21. Debugging
  25. 22. Portability
    1. Why Portability Is Desirable
    2. How to Write Portable Programs
    3. Danger Ahead: When Even Qt Is Not Portable
    4. Building Projects Portably with qmake
  26. 23. Qt Network Programming
    1. Low-Level Socket Access
    2. Higher-Level Network Access
  27. 24. Interfacing Qt with Other Languages and Libraries
    1. OpenGL Programming with Qt
    2. Writing Netscape Plug-ins
    3. Integrating Xt Widgets
    4. Interfacing Qt with Perl
  28. 25. Using the Visual C++ IDE for Qt Programs
    1. Importing an Existing Makefile
    2. Creating Your Own Project from Scratch
    3. Using qmake to Create a Project File
    4. Using the MS Visual Studio Integration
  29. 26. Visual Design with Qt Designer
    1. Why Do You Need A GUI Designer?
    2. Creating a Simple Application with the Help of Qt Designer
      1. Becoming Familiar with Qt Designer
        1. A first look at the property editor
        2. A first look at the form editor
      2. More Widgets for Our Form
        1. Generating C++ source code from the Qt Designer file
      3. Putting It All Together
    3. Adding Functionality to a Dialog Box by Subclassing
      1. Continuing Work on an Already Existing Dialog Box
      2. Adding Functionality to the Push Buttons
      3. Initializing the State of Widgets in the Form
      4. Connecting Widgets to One Another
    4. Using Layout Management
      1. Putting a Form Together with Layouts
      2. Popular Mechanics: Working with Spacers
    5. Useful Techniques
      1. Working with Signals and Slots
        1. The connection tool
        2. The slots tool
      2. Changing the Tab Order
      3. All About Layout Management
      4. Integrating Qt Designer Files into Your Project
      5. Using qmake for Generating and Building Qt Designer Files
      6. Using Project Management
      7. Creating Main Windows
      8. Accessing Databases from Qt Designer
      9. Accessing the Help System
      10. Dynamically Creating Forms at Runtime
      11. Custom Widgets
  30. A. Answers to Exercises
    1. Answers to Exercises in Chapter 2
      1. Answers to Exercises in the Section “Hello, world!”
      2. Answers to Exercises in the Section “Using the Qt Reference Documentation”
      3. Answers to Exercises in the Section “Adding an Exit Button”
      4. Answers to Exercises in the Section “Introduction to Signals and Slots”
      5. Answers to Exercises in the Section “Event Handling and Simple Drawings with QPainter”
    2. Answers to Exercises in Chapter 3
      1. Answers to Exercises in the Section “Adding Menus”
      2. Answers to Exercises in the Section “Adding a Scrolled View”
      3. Answers to Exercises in the Section “Adding a Context Menu”
      4. Answers to Exercises in the Section “File I/O”
  31. Index
  32. Colophon
  33. Special Upgrade Offer
  34. Copyright

Product information

  • Title: Programming with Qt, 2nd Edition
  • Author(s): Matthias Kalle Dalheimer
  • Release date: January 2002
  • Publisher(s): O'Reilly Media, Inc.
  • ISBN: 9780596000646