Book Image

Application Development with Qt Creator - Second Edition

Book Image

Application Development with Qt Creator - Second Edition

Overview of this book

Table of Contents (20 chapters)
Application Development with Qt Creator Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Preface

Whether you're just getting started with programming or you've settled on Qt as the GUI toolkit for your project, Qt Creator is a great choice for an Integrated Development Environment (IDE). In this book, we work to help you make the most of Qt and Qt Creator, showing you almost every facet of using Qt Creator, from its configuration through compiling and debugging applications along with numerous tips and tricks. Along the way, you gain valuable experience not just with Qt Creator as an IDE, but with Qt and Qt Quick as well. After reading this book, you'll be able to:

  • Edit, compile, debug, and run C++ applications using Qt Creator, opening a path to build state-of-the-art console and GUI applications with Qt and with the Standard Template Library (STL)

  • Edit, compile, debug, and run Qt Quick applications using Qt Creator, giving you access to one of the most advanced declarative GUI authoring environments anywhere

  • Design GUI applications using Qt Designer to build either traditional widget-based or Qt Quick applications

  • Analyze the memory and the runtime performance of your Qt applications, make improvements, and fix defects

  • Provide localized versions of your application so that you can deploy it all over the world in different languages

  • Use Qt Quick and Qt Widgets to write mobile applications for platforms such as Google Android

  • Build multimedia- and sensor-aware applications with Qt's support for multimedia and sensors

What this book covers

This book is divided into thirteen chapters, which you should plan to read in order, especially if you're new to Qt Creator and Qt programming in general. These chapters are given as follows:

Chapter 1, Getting Started with Qt Creator, shows you how to download and install Qt Creator as well as edit simple applications to test your installation.

Chapter 2, Building Applications with Qt Creator, shows you how to compile, run, and debug your application using Qt Creator. You will learn how Qt Creator integrates with both the GNU debugger and the Microsoft console debugger to provide breakpoints, memory inspection, and other debugging help.

Chapter 3, Designing Your Application with Qt Designer, shows you how to use the drag-and-drop GUI designer that is a part of Qt Creator to build both Qt Widget-based applications and Qt Quick applications.

Chapter 4, Qt Foundations, takes you through the foundations of software development using Qt and also covers its support for platform-agnostic application development.

Chapter 5, Developing Applications with Qt Widgets, shows you how to build applications using Qt Widgets that look and act like native desktop applications on the platform of your choice.

Chapter 6, Drawing with Qt, shows the various ways you can move beyond the built-in controls in Qt and make your own drawing on the screen and other drawable entities such as image files in PNG or JPEG.

Chapter 7, Doing More with Qt Quick, expands on what you learned about Qt Quick in the introductory chapters.

Chapter 8, Multimedia and Qt Quick, introduces you to Qt Quick's support for multimedia, such as audio and video playback as well as how to use a camera if it is connected.

Chapter 9, Sensors and Qt Quick, shows you how to use the various sensors on many of the devices available today using Qt Quick.

Chapter 10, Localizing Your Application with Qt Linguist, shows you how to manage resource strings for different locales, letting you build your application with different languages in different locales.

Chapter 11, Optimizing Performance with Qt Creator, shows you how to use Qt Creator to examine your Qt Quick application's runtime performance, as well as how to perform the memory profiling of your application with Valgrind, an open source diagnostic tool.

Chapter 12, Developing Mobile Applications with Qt Creator, gives you a glimpse of the exciting arena of mobile software development and shows you how you can use what you've learned in this book about Qt and Qt Creator to write applications for platforms such as Google Android.

Chapter 13, Qt Tips and Tricks, is packed with tricks for using Qt and Qt Creator that will help you use the Qt framework and the Qt Creator IDE efficiently.

What you need for this book

Qt and Qt Creator are cross-platform tools. Whether you're using a Windows machine, a Macintosh using Mac OS X, or a workstation running Linux, you probably have what you need. You should have a reasonable amount of disk space (around 10 GB is enough) to install the whole Qt Creator IDE and Qt libraries. As with any software development environment, the more RAM you have, the better (although I've run Qt Creator on netbooks running Ubuntu with a gigabyte of RAM and survived!).

You should have a basic understanding of computer programming and be prepared to write code in C++. Knowledge of JavaScript is helpful if you're interested in programming with Qt Quick, but you can pick that up along the way with little difficulty.

Who this book is for

If you have little or no experience with Qt and Qt Creator, and might be using it for the first time as part of a college class or an open source project, or you just want to experiment with the platform and the IDE, this is the book for you.

I would especially encourage you to read this book if you're a student using Qt Creator in your university class on C++ programming! You should focus on the first two chapters and as much of the rest as you need for your course.

Conventions

In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "Finally, we have to add the on_exitButton_clicked method declaration to mainwindow.h if it's not already added."

A block of code is set as follows:

QApplication a(argc, argv); 
QTranslator translator; 
bool result = translator.load("QtLinguistExample-epo.qm"); 
a.installTranslator(&translator); 
return a.exec(); 

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

QApplication a(argc, argv); 
QTranslator translator; 
bool result = translator.load("QtLinguistExample-epo.qm"); 
a.installTranslator(&translator); 
return a.exec(); 

Any command-line input or output is written as follows:

# % lupdate -pro .\QtLinguistExample.pro –ts .\QtLinguistExample-epo.ts

New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: "In Qt Creator, select New File or Project… from the File menu."

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of.

To send us general feedback, simply e-mail , and mention the book's title in the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files from your account at http://www.packtpub.com for all the Packt Publishing books you have purchased. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.

To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.

Piracy

Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors and our ability to bring you valuable content.

Questions

If you have a problem with any aspect of this book, you can contact us at , and we will do our best to address the problem.