Programming with Qt: Writing Portable GUI applications on Unix and Win32
522Programming with Qt: Writing Portable GUI applications on Unix and Win32
522eBook
Available on Compatible NOOK devices, the free NOOK App and in My Digital Library.
Related collections and offers
Overview
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 whereProgramming 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.
Product Details
ISBN-13: | 9781449390938 |
---|---|
Publisher: | O'Reilly Media, Incorporated |
Publication date: | 01/22/2002 |
Sold by: | Barnes & Noble |
Format: | eBook |
Pages: | 522 |
File size: | 4 MB |
About the Author
Matthias Kalle Dalheimer is the President & CEO of Klaralvdalens Datakonsult AB, a Sweden-based consultancy specializing in platform-independent software solutions. He is also a founding member of the KDE project and the current president of the KDE foundation. Kalle has written numerous books for O'Reilly, both in English and in his native German, including "Running Linux" and "Programming with Qt". In his spare time, he enjoys cross-country skiing and reading history books. Kalle lives with his wife Tanja and his two sons Jan and Tim in the middle of the forest near Hagfors in the Swedish province of Varmland.
Table of Contents
Preface | xi | |
1. | Introduction | 1 |
Why GUI Toolkits? | 1 | |
Why Portability? | 3 | |
Why Qt? | 3 | |
Implementing Cross-Platform GUI Libraries | 4 | |
Acquiring Qt | 6 | |
Compiling and Installing Qt | 8 | |
C++ as Used by Qt | 16 | |
Getting Help | 17 | |
2. | First Steps in Qt Programming | 19 |
Hello, world! | 19 | |
Using the Qt Reference Documentation | 23 | |
Adding an Exit Button | 26 | |
Introduction to Signals and Slots | 28 | |
Event Handling and Simple Drawings with QPainter | 37 | |
3. | Learning More About Qt | 45 |
Adding Menus | 45 | |
Adding a Scrolled View | 55 | |
Adding a Context Menu | 63 | |
File I/O | 71 | |
4. | A Guided Tour Through the Simple Widgets | 81 |
General Widget Parameters | 85 | |
Widget Styles | 86 | |
Buttons | 88 | |
Selection Widgets | 91 | |
Widgets for Bounded-Range Input | 95 | |
Scrollbars | 100 | |
Menu-Related Widgets | 102 | |
Arrangers | 103 | |
Tab-Related Widgets | 108 | |
Text-Entry Fields | 108 | |
Labels | 110 | |
Widgets for the Office | 113 | |
Progress Bars | 120 | |
Scrolled Views | 121 | |
List Views | 122 | |
Icon Views | 128 | |
Widgets for Tabular Material | 129 | |
Widgets for Displaying Rich Text | 132 | |
5. | A Guided Tour Through the Qt Dialog Boxes | 134 |
Predfined Dialog Boxes | 134 | |
Building Blocks for Your Own Dialog Boxes | 145 | |
6. | Using Layout Managers | 155 |
Layout Manager Basics | 155 | |
Laying Out Widgets in Rows and Columns | 157 | |
Nested Layout Managers | 160 | |
Grid Layout | 162 | |
Implicit Geometry Management | 164 | |
7. | Some Thoughts on GUI Design | 167 |
8. | Container Classes | 173 |
Available Container Classes | 174 | |
Choosing a Container Class | 176 | |
Working with Reference-Based Container Classes | 177 | |
Working with Value-Based Container Classes | 181 | |
9. | Graphics | 184 |
Animations | 184 | |
Printing | 186 | |
Managing Colors | 191 | |
Basic QPainter: Drawing Figures | 196 | |
Advanced QPainter | 198 | |
Double-Buffering and Other Nifty Techniques | 203 | |
Independently Movable Objects with QCanvas | 208 | |
Working with Styles | 213 | |
Loading and Saving Custom Image Formats | 215 | |
Setting a Cursor | 218 | |
10. | Text Processing | 219 |
Internationalization and Localization of On-Screen Text | 219 | |
Validating User Input | 227 | |
Working with Regular Expressions | 232 | |
Reading and Writing XML Files | 237 | |
Rich Text | 245 | |
11. | Working with Files and Directories | 248 |
Reading a Text File | 248 | |
Traversing a Directory | 251 | |
File Information | 253 | |
Reading and Writing Configuration Data | 254 | |
12. | Interapplication Communication | 258 |
Using the Clipboard | 258 | |
Drag-and-Drop | 259 | |
13. | Interfacing with the Operating System | 265 |
Working with Date and Time Values | 265 | |
Loading Code Libraries Dynamically | 266 | |
Spawning Child Processes | 269 | |
Playing Sounds | 271 | |
14. | Writing Your Own Widgets | 274 |
Implementing a Coordinate Selector | 276 | |
Implementing a Browse Box | 285 | |
15. | Focus Handling | 299 |
16. | Advanced Event Handling | 302 |
Event Filters | 302 | |
Sending Synthetic Events | 304 | |
17. | Advanced Signals and Slots | 306 |
Signals and Slots Revisited | 306 | |
Connecting Several Buttons to One Slot | 309 | |
Actions | 310 | |
18. | Providing Help | 313 |
19. | Accessing Databases | 317 |
Installation of the SQL Module | 319 | |
Connecting to a Database | 320 | |
Simple Data Retrieval | 322 | |
Data Retrieval with Cursors | 325 | |
Data Display | 328 | |
Data Manipulation | 337 | |
Anything Else? | 341 | |
20. | Multithreading | 343 |
Configuring Qt for Multithreading | 344 | |
Using Qt's Multithreading Classes | 344 | |
Multithreading Pitfalls | 348 | |
Alternatives to Multithreading | 348 | |
21. | Debugging | 350 |
22. | Portability | 353 |
Why Portability Is Desirable | 353 | |
How to Write Portable Programs | 355 | |
Danger Ahead: When Even Qt Is Not Portable | 356 | |
Building Projects Portably with qmake | 360 | |
23. | Qt Network Programming | 365 |
Low-Level Socket Access | 365 | |
Higher-Level Network Access | 370 | |
24. | Interfacing Qt with Other Languages and Libraries | 375 |
OpenGL Programming with Qt | 375 | |
Writing Netscape Plug-ins | 379 | |
Integrating Xt Widgets | 387 | |
Interfacing Qt with Perl | 389 | |
25. | Using the Visual C++ IDE for Qt Programs | 397 |
Importing an Existing Makefile | 397 | |
Creating Your Own Project from Scratch | 398 | |
Using qmake to Create a Project File | 399 | |
Using the MS Visual Studio Integration | 399 | |
26. | Visual Design with Qt Designer | 400 |
Why Do You Need A GUI Designer? | 400 | |
Creating a Simple Application with the Help of Qt Designer | 401 | |
Adding Functionality to a Dialog Box by Subclassing | 418 | |
Using Layout Management | 427 | |
Useful Techniques | 436 | |
Appendix | Answers to Exercises | 455 |
Bibliography | 477 | |
Index | 479 |